How To Take Backup And Restore A Function App In Azure

In this Blog i would like to explain the steps that will help to take backup from an Azure function app and restoring it when needed.

Usually for Azure WebApp we see the options to set Backup and Restoring as straightforward in the Azure Portal for every web app. But for Function apps which are created with Consumption plan has the Backup setting is in disabled state. Mentioning that option is not available for the appservice plan selected.

How To Take Backup And Restore A Function App In Azure

In this case, we can take the backup by downloading the app service content from overview pane as shown below.

How To Take Backup And Restore A Function App In Azure

How To Take Backup And Restore A Function App In Azure

The downloaded backup can be stored in any location either on your local computer or any storageaccount etc.

Whenever we want to restore this Backup we can restore it using the Azure CLI. We can either use the Azure CLI from the azure portal or we can install the MSI on our computer and can perform the below steps to restore the backup taken in the above steps.

  1. Connect to Azure using the command az login
  2. Set the subscription to the subscription where your function app is created e.g. az account set --subscription xxxxxxxx-xxxxx-xxxxx-xxx-xxxxxxxxxxxx
  3. Get the details of resource group of your function app and the path where the backup is present as Zip.
  4. Execute command 

    az functionapp deployment source config-zip -g <YourRGName> -n <YourFunctionAppName> --src "Your zip file location"
     
  5. Once the restore is successful check your FunctionExtension version is set to 3, if not update it to 3

How To Take Backup And Restore A Function App In Azure

Now it's time to verify by checking the restored Functionapp Functions and checking by testing it using Developer menu Code+Test option Test/Run Feature.

Hope this will help at some point of time in our Azure journey to take backup and restore the important function app where we lost our original code base.