Backing Up Azure App Service
In this post, I will show you how to backup Web apps that are hosted as an Azure App Service in an App Service Plan.
Protect the Service
An App Service or Web app might run in PaaS but your requirements to protect it are probably no different than they would be if it was running in a virtual machine. This is why it is possible, using the Standard and Premium App Service Plan tiers only, to backup your Web apps. The following kinds of data can be protected:
- Web app content
- Any connected (connection string in the settings) databases
Note that the following database types are supported:
- Azure SQL
- Azure Database for MySQL
- Azure Database for PostgreSQL
- MySQL in-app (also an App Service)
There are three requirements to back up a web app:
- The web app must be running on a Standard or Premium tier App Service Plan.
- You will need a storage account to store the backups (Blob storage).
- The entire backup must be no bigger than 10GB, including the web app content, settings, and database content.
The first step for enabling backups is to create a storage account. If you want to use blob tiering (this would require a bit of effort), then you could use a General Purpose v2 (GPv2) storage account. However, if you do not need blob tiering, I would recommend a General Purpose v1 (GPv1) storage account because of the much lower storage transaction charges (often almost unnoticeable in the bill).
With the storage account ready, you can configure backs up in the web app or App Service. Open the App Service that you want to protect in the Azure Portal and browse to Settings > Backups. Click Configure and a Backup Configuration blade should appear:
- Select the storage account.
- Click + to create a private container. I would name this container after the web app or App Service.
- Select the container.
- If you want to schedule backups, then set Scheduled Backup to On and configure a schedule. Fairly static sites might be backed up less frequently.
- Select your retention. Note that 0 means never delete backups.
- Decide if at least one backup should always be retained.
- Choose if any connected databases should be included in the web app backup.
- Click Save to finalize the backup configuration.
It will take a few minutes for the backup to be configured. After that, any scheduled backups will run automatically but you also have the option to run a manual backup.
Running a Manual Backup
You can return to Settings > Backup in the web app to see the status of backups. You also can click the Backup button to manually trigger a backup.
The Backup Storage
You can see the backup data in the storage account. Open the storage account in the Azure Portal or a tool, such as Azure Storage Explorer and browse to Blobs. Then go into the container (folder) that you created to store the web app’s backups in.
Here you will see three files that contain time stamps in their names:
- Log file: A record of the backup operation.
- XML file: A description of the backup configuration at the time of the backup.
- Zip file: A file-based backup of the web content and the database (in the form of an SQL Server portable .bacpac file in the case of Azure SQL)
You can download the zip file from the storage account but you are also given a link for each retained backup in the Backup configuration of the web app.
It is possible to exclude files from your backups, which might be important to you if your backup size exceeds 10GB.
Tip: Azure SQL does its own backups automatically and for free. You can choose to exclude any databases to save capacity.
If you have web content that you wish to exclude from backups then you can do the following:
- Browse the file system of your web app to identify those files. You can use an FTP client, the web app console, or Kudu (open the web app, browse to Deployment Tools > Advanced Tools, and click Go).
- Identify the paths of the files and folders that you want to exclude. For example, a file called image.png in the root of the web app is stored at \site\wwwroot\image.png.
- Create a text file called _backup.filter and put the path of each excluded file/folder into the file – one excluded item per line.
- Upload the _backup.filter file to the root of your web app (\site\wwwroot).
The web app backup will automatically read the _backup.filter file and exclude any listed files or folders from protection.
Restoring a Backup
What good is a backup if you cannot restore it? A Restore button can be found in the Backup configuration of the web app or App Service; press this button and you can start the restore process. Here you can select the backup to restore (or provide a zip file from another App Service or web app), choose to restore to a different App Service or Web App, and decide how you will handle database connection strings and any conflicting host names.
More in Microsoft Azure
Microsoft's Azure AD Conditional Access Service Can Now Require Reauthentication
May 13, 2022 | Rabia Noureen
Microsoft Addresses Cross-Tenant Database Vulnerability in Azure PostgreSQL
Apr 29, 2022 | Rabia Noureen
Microsoft Simplifies IT Monitoring with New Azure Managed Grafana Service
Apr 19, 2022 | Rabia Noureen
Microsoft Adds Ampere ARM CPU Support to Azure Virtual Machines
Apr 5, 2022 | Rabia Noureen
System Center 2022 is Now Available with New Datacenter Management Capabilities
Apr 4, 2022 | Rabia Noureen
Cloud NAS Shootout: Amazon EFS/FSx versus Azure Files
Apr 4, 2022 | Arian Modiramani
Most popular on petri