Site Recovery: replicate, test, fail over, re-protect
Backup answers "give me yesterday's data". Azure Site Recovery (ASR) answers "the region is down, run the service somewhere else now". It replicates VMs continuously to another region, so a failover starts them there from a recovery point a few minutes old. Backup measures loss in hours, ASR in minutes. The exam tests the order of the steps. On-call, the step that matters is the test failover you did last quarter, which tells you whether the real one will work.
Need to know:
- RPO (recovery point objective): how much data you may lose, i.e. how old the newest usable point is. RTO (recovery time objective): how long until the service is back. ASR: RPO of minutes (crash- consistent points every 5 minutes, app-consistent on a schedule), RTO = how long your VMs take to boot and your runbook takes to run.
- Azure-to-Azure replication uses a Recovery Services vault in the target region: West Europe VMs, vault in North Europe. (The same vault type as Backup, a different job.)
- A replicated VM needs the Site Recovery Mobility extension (installed for you), outbound access to the ASR service endpoints, and target resources: a resource group, a VNet (mapped to the source one), storage for the replicas (managed disks), optionally availability zones.
- Recovery plans group VMs into failover order (database first, then app, then web) with scripts/runbooks and manual steps between groups.
The flow
| Step | What happens | Then |
|---|---|---|
| Enable replication | initial replication copies every disk to the target region, then changes stream continuously | the VM is Protected |
| Test failover | a copy of the VM starts in the target region in an isolated (test) network, from a point you pick; production keeps running | check the app, then Cleanup test failover |
| Failover | the VM starts in the target region from a point (latest, latest processed, latest app-consistent, or custom); the source VM is shut down when possible | you can still change the recovery point |
| Commit | makes the failover final: no more changing points | |
| Re-protect | replication now runs from the target back to the source region | later, fail back the same way, and re-protect again |
There is no general-availability CLI for Azure-to-Azure Site Recovery (the site-recovery extension is a preview with long fabric/container/mapping JSON). It is done in the portal (or with PowerShell / REST in automation). In this lab: Console › Cloud portal › Backup and Site Recovery. Each button runs the command shown below.
Doing it
$ az group create -n rg-try-dr -l westeurope -o none
$ az group create -n rg-try-dr-ne -l northeurope -o none
$ az vm create -g rg-try-dr -n vm-try-orders --image Ubuntu2404 --size Standard_B2s --generate-ssh-keys -o none 2>/dev/null
$ az backup vault create -g rg-try-dr -n rsv-try-we -l westeurope -o none
$ az backup vault create -g rg-try-dr-ne -n rsv-try-ne -l northeurope -o none
$ VM=$(az vm show -g rg-try-dr -n vm-try-orders --query id -o tsv)
$ azportal asr enable --vm $VM --vault $(az backup vault show -g rg-try-dr -n rsv-try-we --query id -o tsv)
Replication cannot be enabled: the Recovery Services vault rsv-try-we is in westeurope, the same region as the VM. For Azure-to-Azure disaster recovery the vault must be in the target region (northeurope).
$ azportal asr enable --vm $VM --vault $(az backup vault show -g rg-try-dr-ne -n rsv-try-ne --query id -o tsv)
(simulator) portal action: replication of vm-try-orders to northeurope enabled (initial replication takes about 30 minutes; recovery points every 5 minutes after that)
$ azportal asr test-failover --vm $VM
Test failover cannot start: the initial replication of the VM has not completed.
The first attempt failed for the classic reason: the vault was in the same region as the VM. The test failover is refused until initial replication has finished (about half an hour here, longer for big disks).
After initial replication (the Console shows the replication health), the test, then the real thing:
$ azportal asr test-failover --vm $VM
(simulator) portal action: test failover of vm-try-orders done: vm-try-orders-test runs in northeurope in an isolated test network (cleanup removes it)
$ azportal asr cleanup-test --vm $VM
(simulator) portal action: test failover cleaned up
$ azportal asr failover --vm $VM
(simulator) portal action: failover of vm-try-orders to northeurope done: the source VM was shut down, vm-try-orders now runs in northeurope. Commit (or change the recovery point) next.
$ az vm get-instance-view -g rg-try-dr -n vm-try-orders --query "instanceView.statuses[1].displayStatus" -o tsv
VM deallocated
$ azportal asr commit --vm $VM
(simulator) portal action: failover committed: you can no longer change the recovery point. Re-protect to replicate back.
$ azportal asr reprotect --vm $VM
(simulator) portal action: re-protect started: vm-try-orders now replicates northeurope -> westeurope
What makes a failover actually work
The VMs coming up is the easy part. What breaks in real failovers:
- Networking: the target VNet's address space, NSGs, UDRs and DNS. Clients must find the new addresses (DNS records with short TTLs, Traffic Manager or Front Door in front).
- Everything that isn't the VM: the database (geo-replication or a failover group), storage (RA-GZRS or object replication), Key Vault, identity, the certificates. ASR replicates VMs, not your architecture. A recovery plan's scripts handle the rest.
- Capacity: the target region needs quota for the VM sizes. Check it before the disaster.
- Practice: a test failover per quarter, with the runbook written down and the RTO measured. The test failover is free of production impact, so there is no excuse to skip it.
On the exam (AZ-104 5.2.5, 5.2.6): vault in the target region, initial replication, recovery point types, test failover in an isolated network + cleanup, failover, commit, re-protect, fail back, recovery plans, RPO vs RTO, Backup vs Site Recovery.
In an interview: "What is the difference between Azure Backup and Site Recovery?" - "Backup keeps point-in-time copies for restores: an accidental delete, corruption, ransomware, an audit. It loses hours of data and a restore takes a while. Site Recovery replicates VMs continuously to another region for disaster recovery: RPO of minutes, and you fail over the running service, then re-protect and fail back later. Most production systems need both, and both only count if you have tested them: a restore drill for Backup, a test failover for Site Recovery."
What you can now do
- Enable Azure-to-Azure replication with the vault in the target region.
- Run a test failover, clean it up, fail over, commit and re-protect, in that order.
- Explain RPO and RTO, and what besides the VMs a failover needs.