Azure Site Recovery (ASR) now supports proximity placement groups (PPGs) from the Azure portal. Recall that previously, ASR only supported Proximity placement groups when configured via PowerShell. The new functionality in the portal is a lot more seamless, and I highly recommend it for replicating for failover and failback to a secondary region, any workloads that are configured within proximity placement groups. Recall that proximity placement groups is a construct that enables you to logically group your application components together to avoid network latency between the various tiers of your application.
The use case for this in the context of site recovery is that while PPGs provide optimal network latency for your application, you also want to ensure that in the event of a disaster, your application is not only protected from region-level failure, but also continues to be performant with optimal network latency in the secondary region.
For reference here is a script that you can use to replicate a machine in a proximity placement group to a secondary region.
Set-AzContext -SubscriptionId "enter your subscription Id" #get the VM to be replicated $VM = Get-AzVM -ResourceGroupName "RG Name" -Name "VM Name" Write-Output $VM #Create Resource group in Target region New-AzResourceGroup -Name "RG Name" -Location "target region" #Create recovery vault $vault = New-AzRecoveryServicesVault -Name "Vault name" -ResourceGroupName "Vault RG Name" -Location "Vault location region" Write-Output $vault Set-AzRecoveryServicesAsrVaultContext -Vault $vault $TempASRJob = New-AzRecoveryServicesAsrFabric -Azure -Location 'source region' -Name "AzASRFabric_Name_Source" $PrimaryFabric = Get-AzRecoveryServicesAsrFabric -Name "AzASRFabric_Name_Source" $TempASRJob = New-AzRecoveryServicesAsrFabric -Azure -Location 'destination region' -Name "AzASRFabric_Name_Dest" $RecoveryFabric = Get-AzRecoveryServicesAsrFabric -Name "AzASRFabric_Name_Dest" $TempASRJob = New-AzRecoveryServicesAsrProtectionContainer -InputObject $PrimaryFabric -Name "A2ASourceProtectionContainer" $PrimaryProtContainer = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $PrimaryFabric -Name "A2ASourceProtectionContainer" $TempASRJob = New-AzRecoveryServicesAsrProtectionContainer -InputObject $RecoveryFabric -Name "A2AdestProtectionContainer" $RecoveryProtContainer = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $RecoveryFabric -Name "A2AdestProtectionContainer" $TempASRJob = New-AzRecoveryServicesAsrPolicy -AzureToAzure -Name "PolicyName" -RecoveryPointRetentionInHours 24 -ApplicationConsistentSnapshotFrequencyInHours 4 $ReplicationPolicy = Get-AzRecoveryServicesAsrPolicy -Name "PolicyName" $TempASRJob = New-AzRecoveryServicesAsrProtectionContainerMapping -Name "A2APrimaryToRecovery" -Policy $ReplicationPolicy -PrimaryProtectionContainer $PrimaryProtContainer -RecoveryProtectionContainer $RecoveryProtContainer $SrcToDestPCMapping = Get-AzRecoveryServicesAsrProtectionContainerMapping -ProtectionContainer $PrimaryProtContainer -Name "A2APrimaryToRecovery" $TempASRJob = New-AzRecoveryServicesAsrProtectionContainerMapping -Name "A2ARecoveryToPrimary" -Policy $ReplicationPolicy -PrimaryProtectionContainer $RecoveryProtContainer -RecoveryProtectionContainer $PrimaryProtContainer $DestToSrcPCMapping = Get-AzRecoveryServicesAsrProtectionContainerMapping -ProtectionContainer $RecoveryProtContainer -Name "A2ARecoveryToPrimary" $SrcCacheStorageAccount = New-AzStorageAccount -Name "a2a1srcachestorage" -ResourceGroupName "RG Name" -Location 'Src region' -SkuName Standard_LRS -Kind Storage $DestTargetStorageAccount = New-AzStorageAccount -Name "a2atgtcachestorage" -ResourceGroupName "RG Name" -Location 'target region' -SkuName Standard_LRS -Kind Storage $DestRecoveryVnet = New-AzVirtualNetwork -Name "VNET Name" -ResourceGroupName "RG Name" -Location 'target region' -AddressPrefix "x.x.x.x/24" Add-AzVirtualNetworkSubnetConfig -Name "default" -VirtualNetwork $DestRecoveryVnet -AddressPrefix "x.x.x.x/24" | Set-AzVirtualNetwork $DestRecoveryNetwork = $DestRecoveryVnet.Id $SplitNicArmId = $VM.NetworkProfile.NetworkInterfaces[0].Id.split("/") $NICRG = $SplitNicArmId[4] $NICname = $SplitNicArmId[-1] $NIC = Get-AzNetworkInterface -ResourceGroupName $NICRG -Name $NICname $PrimarySubnet = $NIC.IpConfigurations[0].Subnet $SrcPrimaryNetwork = (Split-Path(Split-Path($PrimarySubnet.Id))).Replace("\","/") $TempASRJob = New-AzRecoveryServicesAsrNetworkMapping -AzureToAzure -Name "SrcToDestPCMapping" -PrimaryFabric $PrimaryFabric -PrimaryAzureNetworkId $SrcPrimaryNetwork -RecoveryFabric $RecoveryFabric -RecoveryAzureNetworkId $DestRecoveryNetwork #Wait and confirm in portal $RecoveryRG = Get-AzResourceGroup -Name "RG Name" -Location "target region" $recPpg = New-AzProximityPlacementGroup -ResourceGroupName "RG Name" -Name "PPG Name" -Location "target region" $recAvs = New-AzAvailabilitySet -ResourceGroupName "RG Name" -Name "ASR Name" -Location "target region" -PlatformUpdateDomainCount 5 -PlatformFaultDomainCount 2 -Sku Aligned -ProximityPlacementGroupId $recPpg.Id # VM to Replicate $OSdiskId = $VM.StorageProfile.OsDisk.ManagedDisk.Id $RecoveryOSDiskAccountType = "Premium_LRS" $RecoveryReplicaDiskAccountType = "Premium_LRS" $OSDiskReplicationConfig = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $SrcCacheStorageAccount.Id ` -DiskId $OSdiskId -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType ` -RecoveryTargetDiskAccountType $RecoveryOSDiskAccountType $DataDiskId1 = $VM.StorageProfile.DataDisks[0].ManagedDisk.Id $RecoveryReplicaDiskAccountType = "Premium_LRS" $RecoveryTargetDiskAccountType = "Premium_LRS" $DataDisk1ReplicationConfig = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $SrcCacheStorageAccount.Id ` -DiskId $DataDiskId1 -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType ` -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType $diskconfigs = @() $diskconfigs += $OSDiskReplicationConfig, $DataDisk1ReplicationConfig $TempASRJob = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -AzureVmId $VM.Id -Name (New-Guid).Guid -ProtectionContainerMapping $SrcToDestPCMapping -AzureToAzureDiskReplicationConfiguration $diskconfigs -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryProximityPlacementGroupId $recPpg.Id -RecoveryAvailabilitySetId $recAvs.Id
To replicate a VM in a PPG from the Azure portal.
Navigate to the Disaster Recovery blade for the VM, under Basics tab, select the Target region and click Next: Advanced settings
Under the Advanced Settings click the drop down to select your target Subscription, VM resource group, Virtual Network, Availability set/Availability zone, and Proximity placement group. Click Review + Start replication button.
Review the replication summary to verify your settings, and click Start replication.
You can view status of the site recovery jobs in the recovery services vault.
Latest posts by Chiyo Odika (see all)
- Replicate Proximity Placement Group workloads in Azure - January 13, 2021
- Azure NetApp Files (ANF) – Deploy with JSON - October 9, 2020
- Addressing Critical ZeroLogon Vulnerability CVE-2020-1472 - September 26, 2020