OnCallReadyStart learning

Azure Lesson 32.36 · Azure IV: Governance, Storage & Backup · 23 min read

Azure Backup: vaults, policies, backup and restore

In plain words

Azure Backup is a bank vault for copies of your computers and data. Every night (or every few hours) it takes a photo of each protected machine and keeps it in the vault for as many days, weeks, months or years as the plan says.

If a machine breaks or someone ruins its data, you pick a photo from before the damage and get the machine, its disks or just one file back. The vault keeps deleted photos for two extra weeks, in case the one deleting them was a burglar.

Azure Backup: vaults, policies, backup and restore

Soft delete and versioning cover a storage account. For whole machines, file shares and databases, the tool is Azure Backup: copies kept in a vault that the protected resource's own admins can't quietly delete, on a schedule, with retention rules, restorable to a point in time. The sentence to remember from this lesson: a backup you have never restored is a hope, not a backup. The exam asks about vault types and policies. On-call is asked "can you restore it by 9?". This lesson covers both.

Need to know: there are two vault types, and the workload decides which one you use.

Recovery Services vaultBackup vault
CLIaz backup ...az dataprotection ...
ProtectsAzure VMs, SQL Server / SAP HANA in VMs, Azure Files, on-premises (MARS agent, MABS/DPM)Azure Blobs, Azure Disks, Azure Database for PostgreSQL, AKS, Data Lake
AlsoSite Recovery (next lesson)

Both are created in a region and protect resources in the same region. Both have soft delete, redundancy settings (LRS, ZRS, GRS) and immutability options.

A Recovery Services vault

$ az group create -n rg-try-bk -l westeurope -o none
$ az vm create -g rg-try-bk -n vm-try-app --image Ubuntu2404 --size Standard_B2s --generate-ssh-keys -o none 2>/dev/null
$ az backup vault create -g rg-try-bk -n rsv-try -l westeurope --query "{name:name, sku:sku.name}" -o table
Name     Sku
-------  ---
rsv-try  RS0
$ az backup vault backup-properties show -g rg-try-bk -n rsv-try --query "[0].properties.{redundancy:storageModelType, softDelete:softDeleteFeatureState, softDeleteDays:softDeleteDuration, crossRegionRestore:crossRegionRestoreFlag}"
{
  "crossRegionRestore": false,
  "redundancy": "GeoRedundant",
  "softDelete": "Enabled",
  "softDeleteDays": 14
}
  • Storage redundancy defaults to GeoRedundant. It can only be changed before the first item is protected, after that it's locked for the vault's life. Decide it first: LRS for dev, GRS (with Cross Region Restore, so you can restore in the paired region yourself) for production.
  • Soft delete: deleted backup data is kept 14 days (configurable 14-180). Turn on always-on soft delete where you can, so nobody can turn it off first and then delete.
$ az backup vault backup-properties set -g rg-try-bk -n rsv-try --backup-storage-redundancy LocallyRedundant --query "[0].properties.storageModelType" -o tsv
LocallyRedundant

Policies

A backup policy = schedule (when) + retention (how long, in daily / weekly / monthly / yearly points) + instant restore (how many days of local snapshots are kept for fast restores).

$ az backup policy list -g rg-try-bk -v rsv-try -o table
Name            Type         ResourceGroup
--------------  -----------  -------------
DefaultPolicy   AzureIaasVM  rg-try-bk
EnhancedPolicy  AzureIaasVM  rg-try-bk
$ az backup policy show -g rg-try-bk -v rsv-try -n DefaultPolicy --query "properties.{type:policyType, runsAt:schedulePolicy.scheduleRunTimes, dailyKeep:retentionPolicy.dailySchedule.retentionDuration.count, instantDays:instantRpRetentionRangeInDays}"
{
  "dailyKeep": 30,
  "instantDays": 2,
  "runsAt": [
    "2026-09-22T23:30:00+00:00"
  ],
  "type": "V1"
}
$ az backup policy show -g rg-try-bk -v rsv-try -n EnhancedPolicy --query "properties.{type:policyType, frequency:schedulePolicy.scheduleRunFrequency, dailyKeep:retentionPolicy.dailySchedule.retentionDuration.count}"
{
  "dailyKeep": 30,
  "frequency": "Daily",
  "type": "V2"
}
Standard policy (V1)Enhanced policy (V2)
Frequencyonce a dayevery 4-24 hours, or daily/weekly
Instant restore snapshots1-5 days1-30 days
Trusted Launch / Premium SSD v2 / Ultra disksnot supportedrequired
Zone-redundant snapshotsnoyes

Your own policy is the default's JSON, edited: az backup policy show ... > p.json, change the schedule or retention, az backup policy create -n daily-35d --policy @p.json. Retention is enforced: the daily count is between 7 and 9999.

Protecting a VM

$ az vm show -g rg-try-bk -n vm-try-app --query securityProfile.securityType -o tsv
TrustedLaunch
$ az backup protection enable-for-vm -g rg-try-bk -v rsv-try --vm vm-try-app --policy-name DefaultPolicy -o none
ERROR: (UserErrorStandardPolicyNotSupportedWithTrustedLaunchVM) (simulator) vm-try-app is a Trusted Launch VM: protect it with an Enhanced policy (EnhancedPolicy, or one of yours with policyType V2).
Code: UserErrorStandardPolicyNotSupportedWithTrustedLaunchVM
Message: (simulator) vm-try-app is a Trusted Launch VM: protect it with an Enhanced policy (EnhancedPolicy, or one of yours with policyType V2).
$ az backup protection enable-for-vm -g rg-try-bk -v rsv-try --vm vm-try-app --policy-name EnhancedPolicy --query "properties.{operation:operation, status:status}"
{
  "operation": "ConfigureBackup",
  "status": "Completed"
}
$ az backup item list -g rg-try-bk -v rsv-try --query "[].{vm:properties.friendlyName, policy:properties.policyName, status:properties.protectionStatus, last:properties.lastBackupStatus}" -o table
Vm          Policy          Status   Last
----------  --------------  -------  ----
vm-try-app  EnhancedPolicy  Healthy

Nothing has been backed up yet: the first backup runs at the policy's time tonight. Before a risky change, take an on-demand backup and keep it until a date:

$ az backup protection backup-now -g rg-try-bk -v rsv-try -c vm-try-app -i vm-try-app --backup-management-type AzureIaasVM --retain-until 22-10-2026 --query "properties.{operation:operation, status:status}"
{
  "operation": "Backup",
  "status": "InProgress"
}
$ az backup job list -g rg-try-bk -v rsv-try --query "[].{operation:properties.operation, status:properties.status, item:properties.entityFriendlyName}" -o table
Operation        Status      Item
---------------  ----------  ----------
Backup           InProgress  vm-try-app
ConfigureBackup  Completed   vm-try-app

A VM backup is two phases: take snapshot (minutes; this is the instant recovery point you can restore from quickly) and transfer data to vault (longer; the vault-standard point that survives the VM and its disks). Jobs run on Azure's clock, not yours: az backup job wait or check back.

Recovery points and restores

$ az backup job wait -g rg-try-bk -v rsv-try -n $(az backup job list -g rg-try-bk -v rsv-try --operation Backup --query "[0].name" -o tsv) --query properties.status -o tsv
Completed
$ az backup recoverypoint list -g rg-try-bk -v rsv-try -c vm-try-app -i vm-try-app --backup-management-type AzureIaasVM -o table
Name         Time                       Consistency
-----------  -------------------------  --------------------
17901077267  2026-09-22T20:01:26+00:00  FileSystemConsistent
$ az backup recoverypoint list -g rg-try-bk -v rsv-try -c vm-try-app -i vm-try-app --backup-management-type AzureIaasVM --query "[0].properties.recoveryPointTierDetails[].type" -o tsv
InstantRP
HardenedRP

The restore options for a VM:

OptionWhat you getWhen
Create a new VMa VM from the point, in a target RG/VNetthe VM is gone, or you want a copy side by side
Restore disksmanaged disks + an ARM template in a staging storage accountyou want to adjust the VM before creating it, or attach disks elsewhere
Replace existingthe VM's disks swapped for the point's (a snapshot of the current ones is kept)roll the same VM back
File recoverya script that mounts the point's volumes on a machineyou need one file, not the VM
Cross Region Restoreany of the above in the paired region (GRS vault, CRR on)the primary region is down
$ az storage account create -n sttrybkstage01 -g rg-try-bk -o none
$ az group create -n rg-try-bk-restore -l westeurope -o none
$ RP=$(az backup recoverypoint list -g rg-try-bk -v rsv-try -c vm-try-app -i vm-try-app --backup-management-type AzureIaasVM --query "[0].name" -o tsv)
$ az backup restore restore-disks -g rg-try-bk -v rsv-try -c vm-try-app -i vm-try-app -r $RP --storage-account sttrybkstage01 --target-resource-group rg-try-bk-restore --query "properties.{operation:operation, status:status}"
{
  "operation": "Restore",
  "status": "InProgress"
}

The staging account must be in the vault's region and be a Standard LRS/GRS account (not ZRS, not Premium). A restore job's failure is often just that. When the job completes, the disks are in the target group and the template to build the VM is in the staging account (the job's extendedInfo names both).

Backup vaults: blobs and disks

Operational backup for blobs keeps the data in the source account (it uses soft delete, versioning and point-in-time restore under the hood: fast restores, but the same account). Vaulted backup copies blobs into the Backup vault, which survives the account being deleted. The vault's managed identity needs a role on what it protects: Storage Account Backup Contributor on the account, Disk Backup Reader on a disk.

$ az dataprotection backup-vault create -g rg-try-bk --vault-name bv-try -l westeurope --storage-setting datastore-type=VaultStore type=LocallyRedundant --query "{name:name, identity:identity.type}"
{
  "identity": "SystemAssigned",
  "name": "bv-try"
}
$ az dataprotection backup-policy get-default-policy-template --datasource-type AzureBlob > blobpol.json
$ az dataprotection backup-policy create -g rg-try-bk --vault-name bv-try -n blob30d --policy @blobpol.json --query name -o tsv
blob30d
$ az dataprotection backup-instance initialize --datasource-type AzureBlob -l westeurope --policy-id $(az dataprotection backup-vault show -g rg-try-bk --vault-name bv-try --query id -o tsv)/backupPolicies/blob30d --datasource-id $(az storage account show -n sttrybkstage01 -g rg-try-bk --query id -o tsv) > bi.json
$ az dataprotection backup-instance create -g rg-try-bk --vault-name bv-try --backup-instance @bi.json 2>&1 | head -1
ERROR: (UserErrorMissingRequiredPermissions) Appropriate permissions to perform the operation is missing. (simulator) The Backup vault's managed identity (3bd41d79-6c20-401a-9f63-da7792ef51d5) needs the Storage Account Backup Contributor role on sttrybkstage01.
$ az role assignment create --assignee $(az dataprotection backup-vault show -g rg-try-bk --vault-name bv-try --query identity.principalId -o tsv) --role "Storage Account Backup Contributor" --scope $(az storage account show -n sttrybkstage01 -g rg-try-bk --query id -o tsv) -o none
$ az dataprotection backup-instance create -g rg-try-bk --vault-name bv-try --backup-instance @bi.json --query properties.currentProtectionState -o tsv
ProtectionConfigured

Backup at scale

Nobody enables backup VM by VM in a real estate. The Azure Policy built-in Configure backup on virtual machines without a given tag to an existing recovery services vault in the same location (09ce66bc-1220-4153-8104-e3f51c936913, deployIfNotExists) protects every VM in its scope with a given vault and policy, unless the VM carries an exclusion tag. It needs a managed identity with a role, and a remediation task for the VMs that already exist: exactly the pattern from the policy lessons. Azure Backup should be enabled for Virtual Machines (auditIfNotExists) only reports.

On the exam (AZ-104 5.2.1-5.2.4): which vault for which workload, vault storage redundancy (locked after the first item) and Cross Region Restore, Standard vs Enhanced policies (Trusted Launch needs Enhanced, hourly backups), retention, on-demand backups, the restore options and their prerequisites (staging account), file recovery, soft delete (14 days, always-on), Backup vault roles for blobs/disks.

In an interview: "How do you know your backups work?" - "I restore them. A scheduled restore drill (restore disks or a new VM into an isolated group, boot it, check the app or a file, record the time it took against our RTO), backup job failure alerts routed to on-call, and a report of items whose last successful backup is older than the policy allows. Until a restore has worked, I don't count it as a backup."

What you can now do

  • Pick the vault type for a workload and set its redundancy before protecting anything.
  • Choose and read a backup policy (Standard vs Enhanced), protect a VM and take an on-demand backup.
  • List recovery points and restore disks (with the staging account rules), and name the other restore options.
  • Protect blobs with a Backup vault and its identity's role, and backups at scale with Azure Policy.

Why it helps

Backups are the safety net for deletion, corruption and ransomware, and the one control every auditor and every incident commander asks about. Knowing the two vault types, how policies set RPO and retention, and the restore options and their pitfalls is the difference between "we restored by 9" and "we have backups, somewhere".

A backup only counts once a restore has worked: this lesson starts the habit.

Commands in this lesson

az

FAQ

Recovery Services vault or Backup vault?

Recovery Services vaults protect Azure VMs, SQL Server and SAP HANA in VMs, Azure Files and on-premises machines, and host Site Recovery. Backup vaults protect blobs, managed disks, Azure Database for PostgreSQL and AKS. Each protects resources in its own region.

Can I change the vault's storage redundancy later?

Only before the first item is protected. After that it is locked; changing it means stopping protection and deleting the data (and waiting out soft delete), or using a new vault. Decide LRS, ZRS or GRS (with Cross Region Restore) up front.

Why is my Trusted Launch VM refused with the default policy?

Trusted Launch VMs need an Enhanced (V2) policy. Enhanced policies also allow backups every 4-24 hours and longer instant restore snapshot retention (up to 30 days). Start a custom policy from the vault's EnhancedPolicy JSON so the type is right.

Why did my restore fail on the storage account?

restore-disks needs a staging storage account in the vault's region, Standard LRS or GRS. ZRS or Premium accounts are refused. It holds the VM configuration and the template used to rebuild the VM. Keep a suitable staging account in each vault region and in the runbook.

How long does Azure keep backup data after I delete it?

With soft delete (on by default), 14 days, configurable up to 180, during which you can undelete it and the vault cannot be deleted. Always-on soft delete stops anyone turning that protection off before deleting.

In an interview Mid

How do you know your backups actually work?

I restore them. A scheduled restore drill: restore disks or a new VM into an isolated resource group, boot it, check the app or a file, and record the time it took against our RTO. Plus backup job failure alerts routed to on-call, and a report of items whose last successful backup is older than the backup policy allows. A successful job only proves the backup ran; until a restore has worked, I don't count it as a backup.

Also asked: What is the difference between a Recovery Services vault and a Backup vault? · What restore options does Azure Backup offer for a VM? · What is soft delete in Azure Backup and why does it matter for ransomware?

Practise this lesson in the terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.