Skip to content

Commit e146b06

Browse files
authored
Merge pull request #116205 from Sharmistha-Rai/master
Added documentation for PPG support
2 parents 7999e93 + bee1649 commit e146b06

File tree

2 files changed

+189
-1
lines changed

2 files changed

+189
-1
lines changed
Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
---
2+
title: Replicate Azure VMs running in Proximity Placement Groups
3+
description: Learn how to replicate Azure VMs running in Proximity Placement Groups using Azure Site Recovery.
4+
author: Sharmistha-Rai
5+
manager: gaggupta
6+
ms.topic: how-to
7+
ms.date: 05/25/2020
8+
9+
---
10+
11+
# Replicate Azure virtual machines running in Proximity Placement Groups to another region
12+
13+
This article describes how to replicate, failover and failback virtual machines running in a Proximity Placement Group to a secondary region.
14+
15+
[Proximity Placement Groups](https://docs.microsoft.com/azure/virtual-machines/windows/proximity-placement-groups-portal) is an Azure Virtual Machine logical grouping capability that you can use to decrease the inter-VM network latency associated with your applications. When the VMs are deployed within the same proximity placement group, they are physically located as close as possible to each other. Proximity placement groups are particularly useful to address the requirements of latency-sensitive workloads.
16+
17+
## Disaster recovery with Proximity Placement Groups
18+
19+
In a typical scenario, you may have your virtual machines running in a proximity placement group to avoid the network latency between the various tiers of your application. While this can provide your application optimal network latency, you would like to protect these applications using Site Recovery for any region level failure. Site Recovery replicates the data from one region to another Azure region and brings up the machines in disaster recovery region in an event of failover.
20+
21+
## Considerations
22+
23+
- The best effort will be to failover/failback the virtual machines into a proximity placement group. However, if VM is unable to be brought up inside Proximity Placement during failover/failback, then failover/failback will still happen, and virtual machines will be created outside of a proximity placement group.
24+
- If an Availability Set is pinned to a Proximity Placement Group and during failover/failback VMs in the availability set have an allocation constraint, then the virtual machines will be created outside of both the availability set and proximity placement group.
25+
- Site Recovery for Proximity Placement Groups is not supported for unmanaged disks.
26+
27+
## Prerequisites
28+
29+
1. Make sure that you have the Azure PowerShell Az module. If you need to install or upgrade Azure PowerShell, follow this [Guide to install and configure Azure PowerShell](https://docs.microsoft.com/powershell/azure/install-az-ps).
30+
31+
## Set up Site Recovery for Virtual Machines in Proximity Placement Group
32+
33+
### Azure to Azure
34+
35+
1. [Sign in](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#sign-in-to-your-microsoft-azure-subscription) to your account and set your subscription.
36+
2. Get the details of the virtual machine you’re planning to replicate as mentioned [here](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#get-details-of-the-virtual-machine-to-be-replicated).
37+
3. [Create](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#create-a-recovery-services-vault) your recovery services vault and [set](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#set-the-vault-context) the vault context.
38+
4. Prepare the vault to start replication virtual machine. This involves creating a [service fabric object](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#create-a-site-recovery-fabric-object-to-represent-the-primary-source-region) for both primary and recovery regions.
39+
5. [Create](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#create-a-site-recovery-protection-container-in-the-primary-fabric) a Site Recovery protection container, for both the primary and recovery fabrics.
40+
6. [Create](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#create-a-replication-policy) a replication policy.
41+
7. Create a protection container mapping between primary and recovery protection container using [these](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#create-a-protection-container-mapping-between-the-primary-and-recovery-protection-container) steps and a protection container mapping for failback as mentioned [here](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#create-a-protection-container-mapping-for-failback-reverse-replication-after-a-failover).
42+
8. Create cache storage account by following [these](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#create-cache-storage-account-and-target-storage-account) steps.
43+
9. Create the required network mappings as mentioned [here](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#create-network-mappings).
44+
10. To replicate Azure virtual machine with managed disks, use the below PowerShell cmdlet –
45+
46+
```azurepowershell
47+
#Get the resource group that the virtual machine must be created in when failed over.
48+
$RecoveryRG = Get-AzResourceGroup -Name "a2ademorecoveryrg" -Location "West US 2"
49+
50+
#Specify replication properties for each disk of the VM that is to be replicated (create disk replication configuration)
51+
52+
#OsDisk
53+
$OSdiskId = $vm.StorageProfile.OsDisk.ManagedDisk.Id
54+
$RecoveryOSDiskAccountType = $vm.StorageProfile.OsDisk.ManagedDisk.StorageAccountType
55+
$RecoveryReplicaDiskAccountType = $vm.StorageProfile.OsDisk.ManagedDisk.StorageAccountType
56+
57+
$OSDiskReplicationConfig = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $EastUSCacheStorageAccount.Id ` -DiskId $OSdiskId -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType ` -RecoveryTargetDiskAccountType $RecoveryOSDiskAccountType -RecoveryProximityPlacementGroupId $recPpg.Id
58+
59+
# Data disk
60+
$datadiskId1 = $vm.StorageProfile.DataDisks[0].ManagedDisk.Id
61+
$RecoveryReplicaDiskAccountType = $vm.StorageProfile.DataDisks[0].ManagedDisk.StorageAccountType
62+
$RecoveryTargetDiskAccountType = $vm.StorageProfile.DataDisks[0].ManagedDisk.StorageAccountType
63+
64+
$DataDisk1ReplicationConfig = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $CacheStorageAccount.Id ` -DiskId $datadiskId1 -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType ` -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType
65+
66+
#Create a list of disk replication configuration objects for the disks of the virtual machine that are to be replicated.
67+
68+
$diskconfigs = @()
69+
$diskconfigs += $OSDiskReplicationConfig, $DataDisk1ReplicationConfig
70+
71+
#Start replication by creating replication protected item. Using a GUID for the name of the replication protected item to ensure uniqueness of name.
72+
73+
$TempASRJob = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -AzureVmId $VM.Id -Name (New-Guid).Guid -ProtectionContainerMapping $EusToWusPCMapping -AzureToAzureDiskReplicationConfiguration $diskconfigs -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryProximityPlacementGroupId $recPpg.Id
74+
```
75+
Once the start replication operation succeeds, virtual machine data is replicated to the recovery region.
76+
77+
The replication process starts by initially seeding a copy of the replicating disks of the virtual machine in the recovery region. This phase is called the initial replication phase.
78+
79+
After initial replication completes, replication moves to the differential synchronization phase. At this point, the virtual machine is protected, and a test failover operation can be performed on it. The replication state of the replicated item representing the virtual machine goes to the Protected state after initial replication completes.
80+
81+
Monitor the replication state and replication health for the virtual machine by getting details of the replication protected item corresponding to it.
82+
83+
```azurepowershell
84+
Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $PrimaryProtContainer | Select FriendlyName, ProtectionState, ReplicationHealth
85+
```
86+
87+
11. To do a test failover, validate and cleanup test failover, follow [these](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#do-a-test-failover-validate-and-cleanup-test-failover) steps.
88+
12. To failover, follow the steps as mentioned [here](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#fail-over-to-azure).
89+
13. To reprotect and failback to the source region, use the below PowerShell cmdlet –
90+
91+
```azurepowershell
92+
#Create Cache storage account for replication logs in the primary region
93+
$WestUSCacheStorageAccount = New-AzStorageAccount -Name "a2acachestoragewestus" -ResourceGroupName "A2AdemoRG" -Location 'West US' -SkuName Standard_LRS -Kind Storage
94+
95+
96+
#Use the recovery protection container, new cache storage account in West US and the source region VM resource group
97+
Update-AzRecoveryServicesAsrProtectionDirection -ReplicationProtectedItem $ReplicationProtectedItem -AzureToAzure -ProtectionContainerMapping $WusToEusPCMapping -LogStorageAccountId $WestUSCacheStorageAccount.Id -RecoveryResourceGroupID $sourceVMResourcegroup.ResourceId -RecoveryProximityPlacementGroupId $vm.ProximityPlacementGroup.Id
98+
```
99+
14. To disable replication, follow the steps [here](https://docs.microsoft.com/azure/site-recovery/azure-to-azure-powershell#disable-replication).
100+
101+
### VMware to Azure
102+
103+
1. Make sure that you [prepare your on-premises VMware servers](https://docs.microsoft.com/azure/site-recovery/vmware-azure-tutorial-prepare-on-premises) for disaster recovery to Azure.
104+
2. Sign in to your account and set your subscription as specified [here](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#log-into-azure).
105+
3. [Set up](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#set-up-a-recovery-services-vault) a Recovery Services Vault and [set vault context](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#set-the-vault-context).
106+
4. [Validate](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#validate-vault-registration) your vault registration.
107+
5. [Create](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#create-a-replication-policy) a replication policy.
108+
6. [Add](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#add-a-vcenter-server-and-discover-vms) a vCenter server and discover virtual machines and [create](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#create-storage-accounts-for-replication) storage accounts for replication.
109+
7. To replicate VMware Virtual Machines, check the details here and follow the below PowerShell cmdlet –
110+
111+
```azurepowershell
112+
#Get the target resource group to be used
113+
$ResourceGroup = Get-AzResourceGroup -Name "VMwareToAzureDrPs"
114+
115+
#Get the target virtual network to be used
116+
$RecoveryVnet = Get-AzVirtualNetwork -Name "ASR-vnet" -ResourceGroupName "asrrg"
117+
118+
#Get the protection container mapping for replication policy named ReplicationPolicy
119+
$PolicyMap = Get-AzRecoveryServicesAsrProtectionContainerMapping -ProtectionContainer $ProtectionContainer | where PolicyFriendlyName -eq "ReplicationPolicy"
120+
121+
#Get the protectable item corresponding to the virtual machine CentOSVM1
122+
$VM1 = Get-AzRecoveryServicesAsrProtectableItem -ProtectionContainer $ProtectionContainer -FriendlyName "CentOSVM1"
123+
124+
# Enable replication for virtual machine CentOSVM1 using the Az.RecoveryServices module 2.0.0 onwards to replicate to managed disks
125+
# The name specified for the replicated item needs to be unique within the protection container. Using a random GUID to ensure uniqueness
126+
$Job_EnableReplication1 = New-AzRecoveryServicesAsrReplicationProtectedItem -VMwareToAzure -ProtectableItem $VM1 -Name (New-Guid).Guid -ProtectionContainerMapping $PolicyMap -ProcessServer $ProcessServers[1] -Account $AccountHandles[2] -RecoveryResourceGroupId $ResourceGroup.ResourceId -logStorageAccountId $LogStorageAccount.Id -RecoveryAzureNetworkId $RecoveryVnet.Id -RecoveryAzureSubnetName "Subnet-1" -RecoveryProximityPlacementGroupId $recPpg.Id
127+
```
128+
8. You can check the replication state and replication health of the virtual machine with the Get-ASRReplicationProtectedItem cmdlet.
129+
130+
```azurepowershell
131+
Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $ProtectionContainer | Select FriendlyName, ProtectionState, ReplicationHealth
132+
```
133+
9. Configure the failover settings by following the steps [here](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#configure-failover-settings).
134+
10. [Run](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#run-a-test-failover) a test failover.
135+
11. Failover to Azure using [these](https://docs.microsoft.com/azure/site-recovery/vmware-azure-disaster-recovery-powershell#fail-over-to-azure) steps.
136+
137+
### Hyper-V to Azure
138+
139+
1. Make sure that you [prepare your on-premises Hyper-V servers](https://docs.microsoft.com/azure/site-recovery/hyper-v-prepare-on-premises-tutorial) for disaster recovery to Azure.
140+
2. [Sign in](https://docs.microsoft.com/azure/site-recovery/hyper-v-azure-powershell-resource-manager#step-1-sign-in-to-your-azure-account) to Azure.
141+
3. [Set up](https://docs.microsoft.com/azure/site-recovery/hyper-v-azure-powershell-resource-manager#step-2-set-up-the-vault) your vault and [set](https://docs.microsoft.com/azure/site-recovery/hyper-v-azure-powershell-resource-manager#step-3-set-the-recovery-services-vault-context) the Recovery Services Vault context.
142+
4. [Create](https://docs.microsoft.com/azure/site-recovery/hyper-v-azure-powershell-resource-manager#step-4-create-a-hyper-v-site) a Hyper-V Site.
143+
5. [Install](https://docs.microsoft.com/azure/site-recovery/hyper-v-azure-powershell-resource-manager#step-5-install-the-provider-and-agent) the provider and agent.
144+
6. [Create](https://docs.microsoft.com/azure/site-recovery/hyper-v-azure-powershell-resource-manager#step-6-create-a-replication-policy) a replication policy.
145+
7. Enable replication by using the below steps –
146+
147+
a. Retrieve the protectable item that corresponds to the VM you want to protect, as follows:
148+
149+
```azurepowershell
150+
$VMFriendlyName = "Fabrikam-app" #Name of the VM
151+
$ProtectableItem = Get-AzRecoveryServicesAsrProtectableItem -ProtectionContainer $protectionContainer -FriendlyName $VMFriendlyName
152+
```
153+
b. Protect the VM. If the VM you're protecting has more than one disk attached to it, specify the operating system disk by using the OSDiskName parameter.
154+
155+
```azurepowershell
156+
$OSType = "Windows" # "Windows" or "Linux"
157+
$DRjob = New-AzRecoveryServicesAsrReplicationProtectedItem -ProtectableItem $VM -Name $VM.Name -ProtectionContainerMapping $ProtectionContainerMapping -RecoveryAzureStorageAccountId $StorageAccountID -OSDiskName $OSDiskNameList[$i] -OS $OSType -RecoveryResourceGroupId $ResourceGroupID -RecoveryProximityPlacementGroupId $recPpg.Id
158+
```
159+
c. Wait for the VMs to reach a protected state after the initial replication. This can take a while, depending on factors such as the amount of data to be replicated, and the available upstream bandwidth to Azure. When a protected state is in place, the job State and StateDescription are updated as follows:
160+
161+
```azurepowershell
162+
$DRjob = Get-AzRecoveryServicesAsrJob -Job $DRjob
163+
$DRjob | Select-Object -ExpandProperty State
164+
165+
$DRjob | Select-Object -ExpandProperty StateDescription
166+
```
167+
d. Update recovery properties (such as the VM role size) and the Azure network to which to attach the VM NIC after failover.
168+
169+
```azurepowershell
170+
$nw1 = Get-AzVirtualNetwork -Name "FailoverNw" -ResourceGroupName "MyRG"
171+
172+
$VMFriendlyName = "Fabrikam-App"
173+
174+
$rpi = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $protectionContainer -FriendlyName $VMFriendlyName
175+
176+
$UpdateJob = Set-AzRecoveryServicesAsrReplicationProtectedItem -InputObject $rpi -PrimaryNic $VM.NicDetailsList[0].NicId -RecoveryNetworkId $nw1.Id -RecoveryNicSubnetName $nw1.Subnets[0].Name
177+
178+
$UpdateJob = Get-AzRecoveryServicesAsrJob -Job $UpdateJob
179+
180+
$UpdateJob | Select-Object -ExpandProperty state
181+
182+
Get-AzRecoveryServicesAsrJob -Job $job | Select-Object -ExpandProperty state
183+
```
184+
8. Run a test [failover](https://docs.microsoft.com/azure/site-recovery/hyper-v-azure-powershell-resource-manager#step-8-run-a-test-failover).
185+
186+
187+
For more information, see [Failover in Site Recovery](site-recovery-failover.md).

articles/site-recovery/toc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,8 @@
388388
href: service-updates-how-to.md
389389
- name: Delete a vault
390390
href: delete-vault.md
391-
391+
- name: Site Recovery support for Proximity Placement Groups
392+
href: how-to-enable-replication-proximity-placement-groups.md
392393
- name: Disaster recovery for apps
393394
items:
394395
- name: About disaster recovery for on-premises apps

0 commit comments

Comments
 (0)