Skip to content

Commit d7920f9

Browse files
Merge changes of newApiVersion/asr2021-02-10 branch
2 parents 3d45cad + fc11807 commit d7920f9

12 files changed

+278
-21
lines changed

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/RecoveryServices.SiteRecovery.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.3.1-preview" />
1717
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.Backup" Version="4.1.5-preview" />
1818
<PackageReference Include="Microsoft.Azure.Management.Storage" Version="14.3.0" />
19-
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.SiteRecovery" Version="2.1.2-preview" />
19+
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.SiteRecovery" Version="2.1.3-preview" />
2020
</ItemGroup>
2121

2222
<ItemGroup>

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,12 @@ public void A2ARecoveryPlanReplication()
117117
{
118118
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-RecoveryPlanReplication");
119119
}
120+
121+
[Fact]
122+
[Trait(Category.AcceptanceType, Category.CheckIn)]
123+
public void A2AVMSSReplication()
124+
{
125+
this.RunPowerShellTest(_logger, Constants.NewModel, "Test-VMSSReplication");
126+
}
120127
}
121128
}

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/A2A/AsrA2ATests.ps1

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -924,4 +924,154 @@ function Test-RecoveryPlanReplication {
924924
#Failover
925925
$failoverjob = Start-AzRecoveryServicesAsrUnPlannedFailoverJob -RecoveryPlan $RecoveryPlan -Direction PrimaryToRecovery -PerformSourceSideAction
926926
WaitForJobCompletion -JobId $failoverjob.Name
927+
}
928+
929+
<#
930+
.SYNOPSIS
931+
Test VMSS replication new parametersets
932+
#>
933+
934+
function Test-VMSSReplication {
935+
param([string] $seed = '1227')
936+
$primaryPolicyName = getPrimaryPolicy
937+
$recoveryPolicyName = getRecoveryPolicy
938+
939+
$primaryContainerMappingName = getPrimaryContainerMapping
940+
$recoveryContainerMappingName = getRecoveryContainerMapping
941+
942+
$primaryContainerName = getPrimaryContainer
943+
$recoveryContainerName = getRecoveryContainer
944+
$vaultRgLocation = getVaultRgLocation
945+
$vaultName = getVaultName
946+
$vaultLocation = getVaultLocation
947+
$vaultRg = getVaultRg
948+
$primaryLocation = getPrimaryLocation
949+
$recoveryLocation = getRecoveryLocation
950+
$primaryFabricName = getPrimaryFabric
951+
$recoveryFabricName = getRecoveryFabric
952+
$RecoveryReplicaDiskAccountType = "Premium_LRS"
953+
$RecoveryTargetDiskAccountType = "Premium_LRS"
954+
$policyName = getPrimaryPolicy
955+
$mappingName = getPrimaryContainerMapping
956+
$recMappingName = getRecoveryContainerMapping
957+
$primaryNetMapping = getPrimaryNetworkMapping
958+
$recoveryNetMapping = getRecoveryNetworkMapping
959+
960+
#create recovery side resources
961+
$recRgName = getRecoveryResourceGroupName
962+
New-AzResourceGroup -name $recRgName -location $recoveryLocation -force
963+
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
964+
$RecoveryAzureNetworkId = createRecoveryNetworkId
965+
$index = $RecoveryAzureNetworkId.IndexOf("/providers/")
966+
$recRg = $RecoveryAzureNetworkId.Substring(0, $index)
967+
#create virtual Machine scale set
968+
$vmssConfig = New-AzVmssConfig -Location $recoveryLocation -PlatformFaultDomainCount 1 -SinglePlacementGroup 0
969+
$recVmss = new-azvmss -resourcegroupname $recRgName -vmscalesetname 'vmss-asr' -virtualmachinescaleset $vmssConfig
970+
$recVmss1 = new-azvmss -resourcegroupname $recRgName -vmscalesetname 'vmss1-asr' -virtualmachinescaleset $vmssConfig
971+
972+
#create primary
973+
$vmName = getAzureVmName
974+
New-AzResourceGroup -name $vmName -location $primaryLocation -force
975+
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
976+
$logStg = createCacheStorageAccount
977+
$recLogStg = createRecoveryCacheStorageAccount
978+
979+
$v2VmId = createAzureVm
980+
$vm = get-azVm -ResourceGroupName $vmName -Name $vmName
981+
$vhdid = $vm.StorageProfile.OSDisk.ManagedDisk.Id
982+
$index = $vm.Id.IndexOf("/providers/")
983+
$Rg = $vm.Id.Substring(0, $index)
984+
$PrimaryAzureNetworkId = $Rg + "/providers/Microsoft.Network/virtualNetworks/" + $vmName
985+
986+
# vault Creation
987+
New-AzResourceGroup -name $vaultRg -location $vaultRgLocation -force
988+
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
989+
New-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName -Location $vaultLocation
990+
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(20 * 1000)
991+
$Vault = Get-AzRecoveryServicesVault -ResourceGroupName $vaultRg -Name $vaultName
992+
Set-ASRVaultContext -Vault $Vault
993+
994+
# fabric Creation
995+
$fabJob = New-AzRecoveryServicesAsrFabric -Azure -Name $primaryFabricName -Location $primaryLocation
996+
WaitForJobCompletion -JobId $fabJob.Name
997+
$fab = Get-AzRecoveryServicesAsrFabric -Name $primaryFabricName
998+
Assert-true { $fab.name -eq $primaryFabricName }
999+
Assert-AreEqual $fab.FabricSpecificDetails.Location $primaryLocation
1000+
1001+
$fabJob = New-AzRecoveryServicesAsrFabric -Azure -Name $recoveryFabricName -Location $recoveryLocation
1002+
WaitForJobCompletion -JobId $fabJob.Name
1003+
$fab = Get-AzRecoveryServicesAsrFabric -Name $recoveryFabricName
1004+
Assert-true { $fab.name -eq $recoveryFabricName }
1005+
Assert-AreEqual $fab.FabricSpecificDetails.Location $recoveryLocation
1006+
$pf = get-asrFabric -Name $primaryFabricName
1007+
$rf = get-asrFabric -Name $recoveryFabricName
1008+
1009+
#Container creation
1010+
$job = New-AzRecoveryServicesAsrProtectionContainer -Name $primaryContainerName -Fabric $pf
1011+
WaitForJobCompletion -JobId $Job.Name
1012+
$pc = Get-asrProtectionContainer -name $primaryContainerName -Fabric $pf
1013+
Assert-NotNull($pc)
1014+
$job = New-AzRecoveryServicesAsrProtectionContainer -Name $recoveryContainerName -Fabric $rf
1015+
WaitForJobCompletion -JobId $Job.Name
1016+
$rc = Get-asrProtectionContainer -name $recoveryContainerName -Fabric $rf
1017+
Assert-NotNull($rc)
1018+
1019+
#create policy and mapping
1020+
$job = New-AzRecoveryServicesAsrPolicy -Name $policyName -RecoveryPointRetentionInHours 12 -AzureToAzure
1021+
WaitForJobCompletion -JobId $job.Name
1022+
$policy = Get-AzRecoveryServicesAsrPolicy -Name $policyName
1023+
$job = New-AzRecoveryServicesAsrProtectionContainerMapping -Name $mappingName -Policy $policy -PrimaryProtectionContainer $pc -RecoveryProtectionContainer $rc
1024+
WaitForJobCompletion -JobId $job.Name
1025+
$mapping = Get-AzRecoveryServicesAsrProtectionContainerMapping -Name $mappingName -ProtectionContainer $pc
1026+
1027+
#network mapping
1028+
$job = New-AzRecoveryServicesAsrNetworkMapping -AzureToAzure -Name $primaryNetMapping -PrimaryFabric $pf -PrimaryAzureNetworkId $PrimaryAzureNetworkId -RecoveryFabric $rf -RecoveryAzureNetworkId $RecoveryAzureNetworkId
1029+
WaitForJobCompletion -JobId $job.Name
1030+
1031+
#Reverse Conatiner mapping
1032+
$job = New-AzRecoveryServicesAsrProtectionContainerMapping -Name $recMappingName -Policy $policy -PrimaryProtectionContainer $rc -RecoveryProtectionContainer $pc
1033+
WaitForJobCompletion -JobId $job.Name
1034+
$revMapping = Get-AzRecoveryServicesAsrProtectionContainerMapping -Name $recMappingName -ProtectionContainer $rc
1035+
1036+
#Reverse network mapping
1037+
$job = New-AzRecoveryServicesAsrNetworkMapping -AzureToAzure -Name $recoveryNetMapping -PrimaryFabric $rf -PrimaryAzureNetworkId $RecoveryAzureNetworkId -RecoveryFabric $pf -RecoveryAzureNetworkId $PrimaryAzureNetworkId
1038+
WaitForJobCompletion -JobId $job.Name
1039+
1040+
#enable Replication
1041+
$v = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -managed -LogStorageAccountId $logStg `
1042+
-DiskId $vhdid -RecoveryResourceGroupId $recRg -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType `
1043+
-RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType
1044+
$enableDRjob = New-AzRecoveryServicesAsrReplicationProtectedItem -AzureToAzure -AzureVmId $vm.Id -Name $vmName -ProtectionContainerMapping $mapping -RecoveryResourceGroupId $recRg -AzureToAzureDiskReplicationConfiguration $v -RecoveryVirtualMachineScaleSetId $recVmss.Id
1045+
WaitForJobCompletion -JobId $enableDRjob.Name
1046+
WaitForIRCompletion -affectedObjectId $enableDRjob.TargetObjectId
1047+
1048+
#Validate vmss Set in replicated vm properties
1049+
$pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName
1050+
Assert-NotNull($pe.providerSpecificDetails.RecoveryVirtualMachineScaleSetId)
1051+
1052+
#Update Vmpropertie
1053+
$updateDRjob = Set-AzRecoveryServicesAsrReplicationProtectedItem -InputObject $pe -RecoveryVirtualMachineScaleSetId $recVmss1.Id
1054+
WaitForJobCompletion -JobId $updateDRjob.Name
1055+
$pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $pc -Name $vmName
1056+
Assert-NotNull($pe.providerSpecificDetails.RecoveryVirtualMachineScaleSetId)
1057+
1058+
#Failover
1059+
$failoverjob = Start-AzRecoveryServicesAsrUnPlannedFailoverJob -ReplicationProtectedItem $pe -Direction PrimaryToRecovery -PerformSourceSideAction
1060+
WaitForJobCompletion -JobId $failoverjob.Name
1061+
#Get recovery vm and verify
1062+
$recvm = get-azVm -ResourceGroupName $recRgName -Name $vmName
1063+
Assert-NotNull($recvm.virtualmachinescaleset.Id);
1064+
1065+
#Switch replication
1066+
$vm = get-azVm -ResourceGroupName $vmName -Name $vmName
1067+
$vhdid = $recvm.StorageProfile.OSDisk.ManagedDisk.Id
1068+
$v = New-AzRecoveryServicesAsrAzureToAzureDiskReplicationConfig -managed -LogStorageAccountId $recLogStg `
1069+
-DiskId $vhdid -RecoveryResourceGroupId $Rg -RecoveryReplicaDiskAccountType $RecoveryReplicaDiskAccountType `
1070+
-RecoveryTargetDiskAccountType $RecoveryTargetDiskAccountType
1071+
[Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestUtilities]::Wait(600 * 1000)
1072+
$Switchjob = Update-AzureRmRecoveryServicesAsrProtectionDirection -AzureToAzure -ProtectionContainerMapping $revMapping[0] -RecoveryResourceGroupId $Rg -ReplicationProtectedItem $pe -RecoveryVirtualMachineScaleSetId $vm.virtualmachinescaleset.Id -AzureToAzureDiskReplicationConfiguration $v
1073+
WaitForJobCompletion -JobId $Switchjob.Name
1074+
1075+
$pe = Get-AzRecoveryServicesAsrReplicationProtectedItem -ProtectionContainer $rc -Name $vmName
1076+
Assert-NotNull($pe.providerSpecificDetails.RecoveryVirtualMachineScaleSetId)
9271077
}

src/RecoveryServices/RecoveryServices.SiteRecovery/Models/PSFabricDetails.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,7 @@ public ASRAzureToAzureSpecificRPIDetails(A2AReplicationDetails details)
13281328
this.RecoveryFabricLocation = details.RecoveryFabricLocation;
13291329
this.RecoveryAvailabilitySet = details.RecoveryAvailabilitySet;
13301330
this.RecoveryProximityPlacementGroupId = details.RecoveryProximityPlacementGroupId;
1331+
this.RecoveryVirtualMachineScaleSetId = details.RecoveryVirtualMachineScaleSetId;
13311332
this.TestFailoverRecoveryFabricObjectId = details.TestFailoverRecoveryFabricObjectId;
13321333
this.MonitoringJobType = details.MonitoringJobType;
13331334
this.MonitoringPercentageCompletion = details.MonitoringPercentageCompletion;
@@ -1440,6 +1441,11 @@ public ASRAzureToAzureSpecificRPIDetails(A2AReplicationDetails details)
14401441
/// </summary>
14411442
public string RecoveryProximityPlacementGroupId { get; set; }
14421443

1444+
/// <summary>
1445+
/// Recovery virtual machine scale set Id.
1446+
/// </summary>
1447+
public string RecoveryVirtualMachineScaleSetId { get; set; }
1448+
14431449
/// <summary>
14441450
/// Synced configuration details of the virtual machine.
14451451
/// </summary>

src/RecoveryServices/RecoveryServices.SiteRecovery/RecoveryServices.SiteRecovery.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<ItemGroup>
1515
<PackageReference Include="AutoMapper" Version="6.2.2" />
1616
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices" Version="4.3.1-preview" />
17-
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.SiteRecovery" Version="2.1.2-preview" />
17+
<PackageReference Include="Microsoft.Azure.Management.RecoveryServices.SiteRecovery" Version="2.1.3-preview" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/NewAzureRmRecoveryServicesAsrReplicationProtectedItem.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,14 @@ public class NewAzureRmRecoveryServicesAsrReplicationProtectedItem : SiteRecover
298298
[ValidateNotNullOrEmpty]
299299
public string RecoveryProximityPlacementGroupId { get; set; }
300300

301+
/// <summary>
302+
/// Gets or sets the resource ID of virtual machine scale set to failover this virtual machine to.
303+
/// </summary>
304+
[Parameter(ParameterSetName = ASRParameterSets.AzureToAzure, HelpMessage = "Specify the virtual machine scale set Id to be used by the failover Vm in target recovery region.")]
305+
[Parameter(ParameterSetName = ASRParameterSets.AzureToAzureWithoutDiskDetails, HelpMessage = "Specify the virtual machine scale set Id to be used by the failover Vm in target recovery region.")]
306+
[ValidateNotNullOrEmpty]
307+
public string RecoveryVirtualMachineScaleSetId { get; set; }
308+
301309
/// <summary>
302310
/// Gets or sets ID of the AvailabilitySet to recover the machine to in the event of a failover.
303311
/// </summary>
@@ -794,7 +802,8 @@ private void AzureToAzureReplication(EnableProtectionInput input)
794802
RecoveryAzureNetworkId = this.RecoveryAzureNetworkId,
795803
RecoverySubnetName = this.RecoveryAzureSubnetName,
796804
RecoveryAvailabilityZone = this.RecoveryAvailabilityZone,
797-
RecoveryProximityPlacementGroupId = this.RecoveryProximityPlacementGroupId
805+
RecoveryProximityPlacementGroupId = this.RecoveryProximityPlacementGroupId,
806+
RecoveryVirtualMachineScaleSetId = this.RecoveryVirtualMachineScaleSetId
798807
};
799808

800809
if (!string.IsNullOrEmpty(this.ReplicationGroupName))

src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/SetAzureRmRecoveryServicesAsrReplicationProtectedItem.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ public class SetAzureRmRecoveryServicesAsrReplicationProtectedItem : SiteRecover
174174
[Parameter]
175175
public string RecoveryProximityPlacementGroupId { get; set; }
176176

177+
/// <summary>
178+
/// Gets or sets the virtual machine scale set Id for replication protected item after failover.
179+
/// </summary>
180+
[Parameter]
181+
public string RecoveryVirtualMachineScaleSetId { get; set; }
182+
177183
/// <summary>
178184
/// Gets or sets the availability set for replication protected item after failover.
179185
/// </summary>
@@ -317,6 +323,7 @@ public override void ExecuteSiteRecoveryCmdlet()
317323
this.IsParameterBound(c => c.RecoveryAvailabilitySet) &&
318324
this.IsParameterBound(c => c.RecoveryAvailabilityZone) &&
319325
this.IsParameterBound(c => c.RecoveryProximityPlacementGroupId) &&
326+
this.IsParameterBound(c => c.RecoveryVirtualMachineScaleSetId) &&
320327
string.IsNullOrEmpty(this.RecoveryCloudServiceId) &&
321328
string.IsNullOrEmpty(this.RecoveryResourceGroupId) &&
322329
string.IsNullOrEmpty(this.LicenseType) &&
@@ -371,6 +378,7 @@ public override void ExecuteSiteRecoveryCmdlet()
371378
var useManagedDisk = this.UseManagedDisk;
372379
var availabilitySetId = this.RecoveryAvailabilitySet;
373380
var proximityPlacementGroupId = this.RecoveryProximityPlacementGroupId;
381+
var virtualMachineScaleSetId = this.RecoveryVirtualMachineScaleSetId;
374382
var availabilityZone = this.RecoveryAvailabilityZone;
375383
var primaryNic = this.PrimaryNic;
376384
var diskIdToDiskEncryptionMap = this.DiskIdToDiskEncryptionSetMap;
@@ -646,6 +654,10 @@ public override void ExecuteSiteRecoveryCmdlet()
646654
? this.RecoveryProximityPlacementGroupId
647655
: providerSpecificDetails.RecoveryProximityPlacementGroupId;
648656

657+
virtualMachineScaleSetId = this.IsParameterBound(c => c.RecoveryVirtualMachineScaleSetId)
658+
? this.RecoveryVirtualMachineScaleSetId
659+
: providerSpecificDetails.RecoveryVirtualMachineScaleSetId;
660+
649661
if (!this.MyInvocation.BoundParameters.ContainsKey(
650662
Utilities.GetMemberName(() => this.RecoveryCloudServiceId)))
651663
{
@@ -713,6 +725,7 @@ public override void ExecuteSiteRecoveryCmdlet()
713725
RecoveryCloudServiceId = this.RecoveryCloudServiceId,
714726
RecoveryResourceGroupId = this.RecoveryResourceGroupId,
715727
RecoveryProximityPlacementGroupId = this.RecoveryProximityPlacementGroupId,
728+
RecoveryVirtualMachineScaleSetId = this.RecoveryVirtualMachineScaleSetId,
716729
RecoveryBootDiagStorageAccountId = this.RecoveryBootDiagStorageAccountId,
717730
ManagedDiskUpdateDetails = managedDiskUpdateDetails,
718731
TfoAzureVMName = this.TfoAzureVMName,

src/RecoveryServices/RecoveryServices.SiteRecovery/ReplicationProtectedItem/UpdateAzureRmRecoveryServicesAsrProtectionDirection.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,14 @@ public class UpdateAzureRmRecoveryServicesAsrProtection : SiteRecoveryCmdletBase
261261
[ValidateNotNullOrEmpty]
262262
public string RecoveryProximityPlacementGroupId { get; set; }
263263

264+
/// <summary>
265+
/// Gets or sets virtual machine scale set Id for protected Vm.
266+
/// </summary>
267+
[Parameter(ParameterSetName = ASRParameterSets.AzureToAzure)]
268+
[Parameter(ParameterSetName = ASRParameterSets.AzureToAzureWithMultipleStorageAccount)]
269+
[ValidateNotNullOrEmpty]
270+
public string RecoveryVirtualMachineScaleSetId { get; set; }
271+
264272
/// <summary>
265273
/// Gets or sets BootDiagnosticStorageAccountId.
266274
/// </summary>
@@ -592,7 +600,8 @@ private void A2ARPIReprotect()
592600
RecoveryCloudServiceId = this.RecoveryCloudServiceId,
593601
RecoveryAvailabilitySetId = this.RecoveryAvailabilitySetId,
594602
RecoveryBootDiagStorageAccountId = this.RecoveryBootDiagStorageAccountId,
595-
RecoveryProximityPlacementGroupId = this.RecoveryProximityPlacementGroupId
603+
RecoveryProximityPlacementGroupId = this.RecoveryProximityPlacementGroupId,
604+
RecoveryVirtualMachineScaleSetId = this.RecoveryVirtualMachineScaleSetId
596605
};
597606

598607
// Fetch the latest Protected item objects

src/RecoveryServices/RecoveryServices/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* Azure Site Recovery support for Availability set for VMware to Azure and HyperV to Azure providers.
2323
* Azure Site Recovery support for TargetVmSize for VMware to Azure and HyperV to Azure providers.
2424
* Azure Site Recovery support for ResourceTagging for VMware to Azure and HyperV to Azure providers.
25+
* Azure Site Recovery support for Virtual Machine Scale Set for Azure to Azure provider.
2526

2627
## Version 3.5.0
2728
* Added Cross Zonal Restore for managed virtual machines.

0 commit comments

Comments
 (0)