4.1.5.5. Configure Backup for an App Service
4.1.5.5. Configure Backup for an App Service
💡 First Principle: App Service keeps two kinds of backup for different jobs. Automatic backups are platform snapshots that you can restore from but can't configure, download, or stop. Custom backups are copies you schedule into your own storage account, so you control frequency, retention, and where the data lives.
Scenario: Before a risky release you want an on-demand copy of a production web app that you can download, plus a schedule that keeps copies for 30 days. Later, a bad deployment corrupts content and you need to roll back with as little production downtime as possible.
What It Is: App Service backup and restore copies an app's file content and configuration so you can restore it over the same app, to a new app, or to a deployment slot. Backup and restore are supported in the Basic, Standard, Premium, and Isolated tiers; Free and Shared plans have neither. In the Basic tier you can back up and restore only the production slot.
Automatic vs. Custom Backups
| Feature | Automatic backups | Custom backups |
|---|---|---|
| Configuration | None; created as soon as the app is in a supported tier | Required: storage account and container |
| Frequency | Hourly, not configurable | On demand, or scheduled no more often than every 2 hours (up to 12 per day) |
| Retention | 30 days, not configurable | 0 to 30 days, or indefinite |
| Maximum size | 30 GB | 10 GB, of which up to 4 GB can be a linked database |
| Downloadable | No | Yes, as blobs in your container |
Partial backups (_backup.filter) | Not supported | Supported |
| Backup over a virtual network | Not supported | Supported |
Automatic backups are stored in the same datacenter as the app, so Microsoft doesn't recommend relying on them for disaster recovery. On-demand custom backups are kept indefinitely.
What a Backup Contains
- Content: everything under
%HOME%for Windows apps or/homefor Linux apps, and persistent storage for custom containers. Run-from-package ZIP content and custom-mounted Azure Storage (such as an Azure Files share) aren't included. - Configuration: when you choose to restore site configuration, native log settings, the Application Insights configuration, and health check settings come back. Networking features (private endpoints, virtual network integration, Hybrid Connections), authentication, managed identities, custom domains, TLS bindings, scale-out settings, and deployment slots are not restored, so you reapply them after restoring to a new app.
- Linked databases (custom only, retiring): a custom backup could include a supported database whose connection string is in the app's Connection strings. Microsoft has removed this option from new custom backup configurations (MySQL and PostgreSQL in November 2025, Azure SQL and SQL Server in April 2026), and existing configurations stop including databases on 31 March 2028. Back up databases with their own native tools.
Configuring Custom Backups
In the app, select Backups > Configure custom backups, choose a storage account in the same subscription and a container, then select Set schedule to set the frequency and retention. Backups authenticate to storage with a SAS; managed identity isn't supported for backup and restore. If the storage account is behind a firewall, the app must use virtual network integration and you must select Backup/restore over virtual network integration. If content exceeds 10 GB, the backup fails, so exclude folders such as logs with a _backup.filter file in site\wwwroot.
Restoring
App Service stops the target app or slot while it restores. To protect production, restore to a deployment slot, check it, and then swap. You can restore to a new app in another region of the same subscription; to reach another subscription, download a custom backup and upload it to a storage account the target can read. Restores must target the same OS platform.
Practical Implementation: Schedule, Take, and Restore Backups with Azure CLI
# Custom schedule: every 12 hours, keep 30 days, always keep at least one backup
az webapp config backup update --resource-group rg-web --webapp-name contoso-web \
--container-url "<container-url-with-SAS>" --frequency 12h --retention 30 --retain-one true
# On-demand custom backup before a release
az webapp config backup create --resource-group rg-web --webapp-name contoso-web \
--container-url "<container-url-with-SAS>" --backup-name pre-release
# Automatic backups appear as snapshots: list them, then restore one by its time property
az webapp config snapshot list --name contoso-web --resource-group rg-web
az webapp config snapshot restore --name contoso-web --resource-group rg-web --time <snapshot-timestamp>
⚠️ Common Pitfall: Restoring straight over the production slot during business hours. The restore stops the app until it completes. Restore into a staging slot and swap instead.
⚠️ Exam Trap: "Hourly backups with no configuration" describes automatic backups, which you can't download or keep beyond 30 days. A requirement to download a backup, keep it longer than 30 days, choose the schedule, or write it to a firewall-protected storage account points to a custom backup. Neither type exists in the Free or Shared tiers.
Key Trade-Offs:
- Automatic vs. custom: Automatic backups cost no setup and cover up to 30 GB, but you can't control them or move them off the platform. Custom backups need a storage account and SAS, cap at 10 GB, and add storage cost, but they're portable and on your schedule.
- Full vs. partial backups: Excluding large static folders keeps a backup under the limit, but a restore leaves the excluded files untouched, so they must be recoverable some other way.
Reflection Question: Why does App Service skip networking, custom domains, and managed identities when it restores configuration to a new app, and what would you script so a restored app is reachable in the same way as the original?