In this blog, I’ll outline the procedures for backing up an Azure function app and restoring it as necessary.
The options to set up backup and restoring for each web app in the Azure Portal are typically simple for Azure WebApp. However, the Backup feature is disabled for Function apps that were developed using the Consumption plan. That option is not accessible for the chosen appservice package, it should be noted.
As seen below, we can take a backup in this situation by downloading the app service content from the overview pane.
The downloaded backup can be kept elsewhere, whether on your computer locally, in a storage account, etc.
The Azure CLI may be used to restore this Backup whenever we need to. To restore the backup created in the previous steps, we can either utilize the Azure CLI through the Azure portal or install the MSI on our machine and follow the procedures below.
- Connect to Azure using the command as login
- Set the subscription to the subscription where your function app is created e.g. az account set –subscription xxxxxxxx-xxxxx-xxxxx-xxx-xxxxxxxxxxxx
- Get the details of resource group of your function app and the path where the backup is present as Zip.
- Execute command
As function app deployment source config-zip with the following parameters: -g YourRGName -n YourFunctionAppName —src “The location of your zip file”
Once the restore is successful check your FunctionExtension version is set to 3, if not update it to 3
Now that everything has been recovered, it’s time to verify by checking the Functionapp Functions and testing it using the Developer menu’s 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.