3.1.4.6. Perform a Failover by Using Azure Site Recovery
3.1.4.6. Perform a Failover by Using Azure Site Recovery
💡 First Principle: A disaster recovery plan is only a hypothesis until you have failed over. Site Recovery therefore separates a rehearsal (test failover) from the real thing (failover), and makes the real thing a two-step decision (fail over, then commit) so you can still change your mind about which recovery point to keep.
Scenario: The VMs you protected in 3.1.4.5 have been replicating to West US 2 for a month. Audit wants proof that the recovery works without touching production. Three weeks later East US has a real outage, and you must bring the app up in West US 2, choose between the fastest recovery and the least data loss, and later return the app to East US.
What It Is: A failover creates VMs in the target region from a recovery point of the replicated data. RPO (recovery point objective) is how much data you can afford to lose, measured in time; RTO (recovery time objective) is how long recovery may take. Your recovery point choice trades one against the other.
Test Failover (the drill)
A test failover creates a copy of the VM in the target region with no impact on ongoing replication or on production. From the replicated item (or a recovery plan) select Test Failover, pick a recovery point, and pick the Azure virtual network the test VM joins. Microsoft recommends a non-production network, and specifically not the network created when you enabled replication, so that IP addresses and networking components stay available in the production networks. After validating, select Cleanup test failover, record your observations in Notes, and select Testing is complete; Site Recovery deletes the VMs the drill created. Microsoft's recovery plan guidance is to rerun the drill until the app recovers cleanly, and to repeat it for each app every quarter.
Choosing a Recovery Point
| Option | What it does | Optimizes for |
|---|---|---|
| Latest processed | Uses the newest recovery point Site Recovery has already processed. No processing at failover time. | Lowest RTO |
| Latest | First processes all data already sent to Site Recovery, creating a recovery point for each VM, then fails over to it. | Lowest RPO |
| Latest app-consistent | Uses the newest app-consistent point (only exists if the replication policy takes app-consistent snapshots). | Application consistency |
| Custom | A specific earlier point, for example one taken before corruption started. | Precision; single-VM failover only, not available for recovery plans |
Recovery plans with replication groups also offer Latest multi-VM processed and Latest multi-VM app-consistent, which fail the group over to a common point.
Running the Failover
- On the replicated item or recovery plan, select Failover and choose a recovery point.
- Optionally select Shut down machine before beginning failover. Site Recovery tries to shut the source VMs down first to avoid data loss, but the failover continues even if shutdown fails, which is what you need when the source region is down.
- Check the VM in the target region. If the data isn't right, use Change recovery point to try a different one.
- Select Commit. Commit deletes all available recovery points for the VM, so you can no longer change the recovery point.
Planned vs. unplanned: For Azure VMs there is a single Failover action (the PowerShell cmdlet is Start-AzRecoveryServicesAsrUnplannedFailoverJob). A planned move is that same action with the shutdown option selected while the source is still healthy. The separate Planned failover option, which shuts the source down first and synchronizes the latest data for zero data loss, belongs to Hyper-V-to-Azure replication, not to Azure-to-Azure.
Re-protect and Fail Back
Failed-over VMs start in the target region unprotected. To return home:
- Re-protect the VM (status must be Failover committed, and the primary region must be reachable). Replication now runs secondary to primary. If the original source disks are still accessible, Site Recovery compares the disks and transfers only the differences; it can't reprotect if the source data was deleted or is inaccessible (for example, after its resource group was deleted). While reprotection runs, Site Recovery places a read-only lock on the original source VM.
- Fail over again, this time from secondary to primary. This is the failback. Commit it.
- Re-protect once more so the VM replicates primary to secondary again and is covered for the next disaster.
When you fail over to the target and reprotect, the source VM and its resources are not deleted; when you fail back and reprotect, the VM in the disaster recovery region is deleted.
Practical Implementation: Drill, Failover, Commit, and Re-protect with PowerShell
$rpi = Get-AzRecoveryServicesAsrReplicationProtectedItem -FriendlyName "AzureDemoVM" `
-ProtectionContainer $PrimaryProtContainer
# Drill into an isolated test VNet, then clean up
Start-AzRecoveryServicesAsrTestFailoverJob -ReplicationProtectedItem $rpi `
-AzureVMNetworkId $TFONetwork -Direction PrimaryToRecovery
Start-AzRecoveryServicesAsrTestFailoverCleanupJob -ReplicationProtectedItem $rpi
# Real failover to a chosen recovery point, then commit
$points = Get-AzRecoveryServicesAsrRecoveryPoint -ReplicationProtectedItem $rpi |
Sort-Object RecoveryPointTime
Start-AzRecoveryServicesAsrUnplannedFailoverJob -ReplicationProtectedItem $rpi `
-Direction PrimaryToRecovery -RecoveryPoint $points[-1]
Start-AzRecoveryServicesAsrCommitFailoverJob -ReplicationProtectedItem $rpi
# Re-protect: replicate back toward the original region
Update-AzRecoveryServicesAsrProtectionDirection -ReplicationProtectedItem $rpi -AzureToAzure `
-ProtectionContainerMapping $WusToEusPCMapping -LogStorageAccountId $WestUSCacheStorageAccount.Id `
-RecoveryResourceGroupID $sourceVMResourcegroup.ResourceId
The recovery point list isn't guaranteed to be in time order, so sort it before picking the newest; the times it returns are in UTC.
Visual: Failover Lifecycle
⚠️ Common Pitfall: Running the drill in the VNet that Site Recovery created for real failovers, or in a network peered to production. Site Recovery gives the test VM the source VM's static IP address when that address is free in the chosen network, so a drill on a reachable network can collide with production. Use an isolated network.
⚠️ Exam Trap: "Latest" and "Latest processed" sound alike but sit at opposite ends of the trade-off. Latest processed = fastest (lowest RTO); Latest = least data loss (lowest RPO), because it processes pending data first. Also, Custom can't be used with a recovery plan, and nothing can be undone after Commit.
Key Trade-Offs:
- RTO vs. RPO: Latest processed starts immediately; Latest waits for processing but loses less data.
- Crash vs. App Consistency: An app-consistent point is cleaner for databases but is usually older than the latest crash-consistent point.
- Commit Early vs. Keep Options: Committing frees you to re-protect, but deletes the recovery points you might have switched to.
Reflection Question: During a real outage, how would you decide between Latest processed, Latest, and Latest app-consistent for a SQL Server VM, and what has to happen before you can fail the VM back to its original region?