@@ -181,6 +181,25 @@ Write-Output $TempASRJob.State
181
181
$PrimaryProtContainer = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $PrimaryFabric -Name "A2AEastUSProtectionContainer"
182
182
```
183
183
184
+ ### Create a Site Recovery protection container in the recovery fabric
185
+
186
+ ``` powershell
187
+ #Create a Protection container in the recovery Azure region (within the Recovery fabric)
188
+ $TempASRJob = New-AzRecoveryServicesAsrProtectionContainer -InputObject $RecoveryFabric -Name "A2AWestUSProtectionContainer"
189
+
190
+ #Track Job status to check for completion
191
+ while (($TempASRJob.State -eq "InProgress") -or ($TempASRJob.State -eq "NotStarted")){
192
+ sleep 10;
193
+ $TempASRJob = Get-AzRecoveryServicesAsrJob -Job $TempASRJob
194
+ }
195
+
196
+ #Check if the Job completed successfully. The updated job state of a successfully completed job should be "Succeeded"
197
+
198
+ Write-Output $TempASRJob.State
199
+
200
+ $RecoveryProtContainer = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $RecoveryFabric -Name "A2AWestUSProtectionContainer"
201
+ ```
202
+
184
203
#### Fabric and container creation when enabling zone to zone replication
185
204
186
205
When enabling zone to zone replication, only one fabric will be created. But there will be two containers. Assuming that the region is West Europe, use following commands to get the primary and protection containers -
@@ -342,9 +361,277 @@ A network mapping maps virtual networks in the primary region to virtual network
342
361
#Check if the Job completed successfully. The updated job state of a successfully completed job should be "Succeeded"
343
362
Write-Output $TempASRJob.State
344
363
364
+ ## Create a Site Recovery protection cluster
365
+
366
+ The protection cluster is a container used to group replicated items that are part of a shared disk cluster.
367
+
368
+ ```powershell
369
+ $clusterjob = New-AzRecoveryServicesAsrReplicationProtectionCluster -AzureToAzure -Name $clusterName -ProtectionContainerMapping $forwardpcm
370
+ ```
371
+
372
+ #### Get by name
373
+
374
+ ``` powershell
375
+ $clusters = Get-AzRecoveryServicesAsrReplicationProtectionCluster -ProtectionContainer $pc -Name "3nodecluster"
376
+ ```
377
+
378
+ #### List protection clusters in vault
379
+
380
+ ``` powershell
381
+ Get-AzRecoveryServicesAsrReplicationProtectionCluster
382
+ ```
383
+
384
+
385
+ #### List protection clusters in protection container
386
+
387
+ ``` Get-AzRecoveryServicesAsrReplicationProtectionCluster -Name $clusterName -ProtectionContainer $pc ```
388
+
389
+ ##
390
+
391
+ Replicate the Azure virtual machines with managed shared disks when disk details are unavailable.
392
+
393
+
394
+
395
+ $EnableJob1 = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -Name $rpiName1 -ReplicationProtectionCluster $cluster `
396
+
397
+ -AzureVmId $vmId1 -ProtectionContainerMapping $forwardpcm -RecoveryResourceGroupId $rgId -RecoveryAvailabilitySetId $avset `
398
+
399
+ -RecoveryProximityPlacementGroupId $ppg -RecoveryAzureNetworkId $networkId -LogStorageAccountId $storageId
400
+
401
+
402
+
403
+ Replicate the Azure virtual machines with managed shared disks when disk details are available.
404
+
405
+
406
+
407
+ $disk1 = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $storageId `
408
+
409
+ -DiskId $vhdId1 -RecoveryResourceGroupId $rgId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType `
410
+
411
+ -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType
412
+
413
+ $disk2 = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $storageId `
414
+
415
+ -DiskId $vhdId2 -RecoveryResourceGroupId $rgId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType `
416
+
417
+ -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType
418
+
419
+ $disks = @()
420
+
421
+ $disks += $disk1
422
+
423
+ $disks += $disk2
424
+
425
+
426
+
427
+ $EnableJob2 = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -Name $rpiName2 `
428
+
429
+ -AzureToAzureDiskReplicationConfiguration $disks -ReplicationProtectionCluster $cluster -AzureVmId $vmId2 `
430
+
431
+ -ProtectionContainerMapping $forwardpcm -RecoveryResourceGroupId $rgId -RecoveryAvailabilitySetId $avset `
432
+
433
+ -RecoveryProximityPlacementGroupId $ppg -RecoveryAzureNetworkId $networkId
434
+
435
+
436
+
437
+ The AzureToAzureDiskReplicationConfiguration should contain both the normal disks and shared disk information.
438
+
439
+
440
+
441
+ Example: Enabling protection for 2 VMs in a WSFC cluster with 1 shared disk and are part of Avset and PPG
442
+
443
+
444
+
445
+ $RecoveryRG = Get-AzResourceGroup -Name "a2ademorecoveryrg" -Location "West US 2"
446
+
447
+ $Avset = "/subscriptions/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/ClusterRG-asr/providers/Microsoft.Compute/availabilitySets/SDGQL-AS-asr"
448
+
449
+ $Ppg = "/subscriptions/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/ClusterRG-asr/providers/Microsoft.Compute/proximityPlacementGroups/sdgql-ppg-asr"
450
+
451
+ $NetworkId = "/subscriptions/xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/resourceGroups/ClusterRG-asr/providers/Microsoft.Network/virtualNetworks/adVNET-asr"
452
+
453
+
454
+
455
+ $EnableJob1 = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -Name (New-Guid).Guid -ReplicationProtectionCluster $cluster `
456
+
457
+ -AzureVmId $VM1.Id -ProtectionContainerMapping $EusToWusPCMapping -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryAvailabilitySetId $Avset `
458
+
459
+ -RecoveryProximityPlacementGroupId $Ppg -RecoveryAzureNetworkId $NetworkId -LogStorageAccountId $EastUSCacheStorageAccount.Id
460
+
461
+
462
+
463
+ #OsDisk
464
+
465
+ $OSdiskId = $vm2.StorageProfile.OsDisk.ManagedDisk.Id
466
+
467
+ $RecoveryOSDiskAccountType = $vm2.StorageProfile.OsDisk.ManagedDisk.StorageAccountType
468
+
469
+ $RecoveryReplicaDiskAccountType = $vm2.StorageProfile.OsDisk.ManagedDisk.StorageAccountType
470
+
471
+
472
+
473
+ $OSDiskReplicationConfig = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $EastUSCacheStorageAccount.Id `
474
+
475
+ -DiskId $OSdiskId -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType `
476
+
477
+ -RecoveryTargetDiskAccountType $RecoveryOSDiskAccountType
478
+
479
+
480
+
481
+ # Data disk
482
+
483
+ $datadiskId1 = $vm2.StorageProfile.DataDisks[ 0] .ManagedDisk.Id
484
+
485
+ $RecoveryReplicaDiskAccountType = $vm2.StorageProfile.DataDisks[ 0] .ManagedDisk.StorageAccountType
486
+
487
+ $RecoveryTargetDiskAccountType = $vm2.StorageProfile.DataDisks[ 0] .ManagedDisk.StorageAccountType
488
+
489
+
490
+
491
+ $DataDisk1ReplicationConfig = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -ManagedDisk -LogStorageAccountId $EastUSCacheStorageAccount.Id `
492
+
493
+ -DiskId $datadiskId1 -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType `
494
+
495
+ -RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType
496
+
497
+
498
+
499
+ #Create a list of disk replication configuration objects for the disks of the virtual machine that are to be replicated.
500
+
501
+ $diskconfigs = @()
502
+
503
+ $diskconfigs += $OSDiskReplicationConfig, $DataDisk1ReplicationConfig
504
+
505
+
506
+
507
+ $EnableJob2 = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -Name (New-Guid).Guid `
508
+
509
+ -AzureToAzureDiskReplicationConfiguration $diskconfigs-ReplicationProtectionCluster $cluster -AzureVmId $VM2.Id `
510
+
511
+ -ProtectionContainerMapping $EusToWusPCMapping -RecoveryResourceGroupId $RecoveryRG.ResourceId -RecoveryAvailabilitySetId $Avset `
512
+
513
+ -RecoveryProximityPlacementGroupId $Ppg -RecoveryAzureNetworkId $NetworkId
514
+
515
+
516
+
517
+
518
+
519
+ Recovery points
520
+
521
+ List
522
+
523
+ Get-AzRecoveryServicesAsrClusterRecoveryPoint -ReplicationProtectionCluster $cluster
524
+
525
+
526
+
527
+ Get
528
+
529
+ Get-AzRecoveryServicesAsrClusterRecoveryPoint -ReplicationProtectionCluster $cluster -Name "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
530
+
531
+
532
+
533
+
534
+
535
+ Test Failover
536
+
537
+ Test the fail over of the cluster to a specific recovery point.
538
+
539
+ $tfoJob = Start-AzRecoveryServicesAsrClusterTestFailoverJob -ReplicationProtectionCluster $protectionCluster -Direction PrimaryToRecovery -AzureVMNetworkId "/subscriptions/xxxxxxxxx/resourceGroups/ClusterRG-asr/providers/Microsoft.Network/virtualNetworks/adVNET-asr" -LatestProcessedRecoveryPoint
540
+
541
+
542
+
543
+
544
+
545
+ Test Failover Cleanup
546
+
547
+ Cleanup the test failover after completion of testing
548
+
549
+ Start-AzRecoveryServicesAsrClusterTestFailoverCleanupJob -ReplicationProtectionCluster $protectionCluster
550
+
551
+
552
+
553
+ Failover
554
+
555
+ Fail over the cluster to a specific recovery point.
556
+
557
+ $rpi1 = Get-ASRReplicationProtectedItem -ProtectionContainer $protectionContainer -FriendlyName "sdgql1"
558
+
559
+ $rpi2 = Get-ASRReplicationProtectedItem -ProtectionContainer $protectionContainer -FriendlyName "sdgql2"
560
+
561
+ $nodeRecoveryPoint1 = Get-ASRRecoveryPoint -ReplicationProtectedItem $rpi1
562
+
563
+ $nodeRecoveryPoint2 = Get-ASRRecoveryPoint -ReplicationProtectedItem $rpi2
564
+
565
+
566
+
567
+ $nodeRecoveryPoints = @($nodeRecoveryPoint1[-1].ID, $nodeRecoveryPoint2[-1].ID)
568
+
569
+ $clusterRecoveryPoints = Get-AzRecoveryServicesAsrClusterRecoveryPoint -ReplicationProtectionCluster $protectionCluster
570
+
571
+
572
+
573
+ $ufoJob = Start-AzRecoveryServicesAsrClusterUnplannedFailoverJob -ReplicationProtectionCluster $protectionCluster -Direction PrimaryToRecovery -ClusterRecoveryPoint $clusterRecoveryPoints[-1] -ListNodeRecoveryPoint $nodeRecoveryPoints
574
+
575
+
576
+
577
+ Change Pit
578
+
579
+ $rpi1 = Get-ASRReplicationProtectedItem -ProtectionContainer $protectionContainer -FriendlyName "sdgql1"
580
+
581
+ $rpi2 = Get-ASRReplicationProtectedItem -ProtectionContainer $protectionContainer -FriendlyName "sdgql2"
582
+
583
+ $nodeRecoveryPoint1 = Get-ASRRecoveryPoint -ReplicationProtectedItem $rpi1
584
+
585
+ $nodeRecoveryPoint2 = Get-ASRRecoveryPoint -ReplicationProtectedItem $rpi2
586
+
587
+
588
+
589
+ $nodeRecoveryPoints = @($nodeRecoveryPoint1[-1].ID, $nodeRecoveryPoint2[-1].ID)
590
+
591
+ $clusterRecoveryPoints = Get-AzRecoveryServicesAsrClusterRecoveryPoint -ReplicationProtectionCluster $protectionCluster
592
+
593
+ $changePitJob = Start-AzRecoveryServicesAsrApplyClusterRecoveryPoint -ReplicationProtectionCluster $protectionCluster -ClusterRecoveryPoint $clusterRecoveryPoints[ -1] -ListNodeRecoveryPoint $nodeRecoveryPoints
594
+
595
+
596
+
597
+ Commit Failover
598
+ $CommitFailoverJob = Start-AzRecoveryServicesAsrClusterCommitFailoverJob -ReplicationProtectionCluster $protectionCluster
599
+
600
+
601
+
602
+ Reprotect
603
+
604
+ After failover, protect the Cluster in the new source region back and failover to the new target region.
605
+
606
+ $storage = "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/vijami-alertrg/providers/Microsoft.Storage/storageAccounts/yerp1nvijamitestasrcache"
607
+
608
+ $ppg = "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/ClusterRG-Vijami-1003165924/providers/Microsoft.Compute/proximityPlacementGroups/sdgql-ppg"
609
+
610
+ $avset = "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/ClusterRG-Vijami-1003165924/providers/Microsoft.Compute/availabilitySets/SDGQL-AS"
611
+
612
+ $rgId = "/subscriptions/7c943c1b-5122-4097-90c8-861411bdd574/resourceGroups/ClusterRG-Vijami-1003165924"
613
+
614
+
615
+
616
+ # Without protected item details
617
+
618
+ $recoveryFabricName = "asr-a2a-default-westus"
619
+
620
+ $recoveryFabric = Get-AzRecoveryServicesAsrFabric -Name $recoveryFabricName
621
+
622
+ $recoverypc = Get-AzRecoveryServicesAsrProtectionContainer -Fabric $recoveryFabric
623
+
624
+ $recoverypcm = Get-AzRecoveryServicesAsrProtectionContainerMapping -ProtectionContainer $recoverypc -Name "westus-eastus2-24-hour-retention-policy"
625
+
626
+ $ReprotectJob = Update-AzRecoveryServicesAsrClusterProtectionDirection -AzureToAzure -ReplicationProtectionCluster $cluster `
627
+
628
+ -RecoveryProximityPlacementGroupId $ppg -RecoveryAvailabilitySetId $avset `
345
629
630
+ -RecoveryResourceGroupId $rgId -LogStorageAccountId $storage -ProtectionContainerMapping $recoverypcm
346
631
632
+
347
633
634
+ After reprotection is complete, you can fail over in the reverse direction, West US to East US, and fail back to source region using Failover.
348
635
349
636
350
637
0 commit comments