Backup and Restore for App Services

This document provides comprehensive guidance on configuring and managing backup and restore operations for your Azure App Services. Ensuring your application data and configuration are protected against accidental deletion, corruption, or service outages is critical for business continuity.

Note: Backup and restore functionality is available for Standard, Premium, and Isolated pricing tiers of Azure App Services.

Automatic Backups

Azure App Services offers automated backup capabilities that can be scheduled at regular intervals. These backups can include your application's file content and its associated database (if configured).

To configure automatic backups:

  1. Navigate to your App Service in the Azure portal.
  2. In the left-hand menu, under "Backup + Restore," select "Backup."
  3. Click "Setup backup."
  4. Choose a storage account and container where backups will be stored.
  5. Select the frequency (daily or weekly) and the time for backups.
  6. Optionally, configure database backup settings if your app uses a supported database service (e.g., SQL Database, MySQL).
  7. Click "Save."

Manual Backups

In addition to automatic backups, you can initiate a manual backup at any time. This is useful before making significant changes to your application or its configuration.

To perform a manual backup:

  1. Navigate to your App Service in the Azure portal.
  2. In the left-hand menu, under "Backup + Restore," select "Backup."
  3. Click the "Backup now" button.
  4. Choose a storage account and container, and provide a name for the backup.
  5. Click "OK."

Tip: Regularly review your backup settings and test your restore process to ensure it meets your recovery point objectives (RPO).

Restore Options

When restoring your App Service, you have the flexibility to restore to a specific point in time or to overwrite the current application.

To restore your App Service:

  1. Navigate to your App Service in the Azure portal.
  2. In the left-hand menu, under "Backup + Restore," select "Restore."
  3. Select the backup you wish to restore from the list.
  4. Choose the restore option: "Overwrite" or "Restore to new app."
  5. If restoring to a new app, provide a name and resource group for the new App Service.
  6. Click "Restore."

Advanced Restore

For more granular control over the restore process, you can use Azure CLI or PowerShell. These tools allow you to specify specific files or folders to restore, or to restore only the database content.

Using Azure CLI:

az webapp backup create --resource-group <resource-group-name> --name <app-name> --container-url <sas-url> --backup-name <backup-name>

az webapp restore --resource-group <resource-group-name> --name <app-name> --source-backup-id <backup-id> --target-app-name <target-app-name> --overwrite

Using Azure PowerShell:

New-AzWebAppBackup -ResourceGroupName <resource-group-name> -Name <app-name> -StorageAccountUrl <storage-account-url> -ContainerName <container-name> -BackupName <backup-name>

Restore-AzWebAppBackup -ResourceGroupName <resource-group-name> -Name <app-name> -BackupId <backup-id> -TargetAppName <target-app-name> -Overwrite

Warning: Restoring to overwrite the current app is a destructive operation. Ensure you have a reliable backup before proceeding and understand the implications.

For further details and specific scenarios, refer to the official Azure documentation on App Service backups.