Skip to content

Commit 9b6109c

Browse files
authored
[RecoveryServices.Backup] Added support for passing DiskEncryptionSetId for Cross region restore (#20295)
* Added CZR test case added CRR DES support re-recorded failed test * fixing the issue in playback mode
1 parent 50c2db9 commit 9b6109c

File tree

7 files changed

+3340
-4
lines changed

7 files changed

+3340
-4
lines changed

src/RecoveryServices/RecoveryServices.Backup.Models/Properties/Resources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ Please contact Microsoft for further assistance.</value>
755755
<value>ResourceGuardMapping not found</value>
756756
</data>
757757
<data name="DisableWithRetainBackupNotCrititcal" xml:space="preserve">
758-
<value>Invalid parameter Token: Stop protection with retain backup data is not MUA protected</value>
758+
<value>Invalid parameter Token. Stop protection with retain backup data is not MUA protected</value>
759759
</data>
760760
<data name="CRRNotSupportedWIthCSR" xml:space="preserve">
761761
<value>Cross region restore is not supported along with cross subscription restore, please try passing either RestoreToSecondaryRegion or TargetSubscriptionId parameter but not both</value>

src/RecoveryServices/RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,18 @@ public void TestAzureMonitorAlerts()
256256
$"Import-Module {_IaasVmtestModule.AsAbsoluteLocation()}",
257257
"Test-AzureMonitorAlerts"
258258
);
259-
}
259+
}
260+
261+
[Fact]
262+
[Trait(Category.AcceptanceType, Category.CheckIn)]
263+
[Trait(TestConstants.Workload, TestConstants.AzureVM)]
264+
public void TestAzureCrossZonalRestore()
265+
{
266+
TestRunner.RunTestScript(
267+
$"Import-Module {_IaasVmcommonModule.AsAbsoluteLocation()}",
268+
$"Import-Module {_IaasVmtestModule.AsAbsoluteLocation()}",
269+
"Test-AzureCrossZonalRestore"
270+
);
271+
}
260272
}
261273
}

src/RecoveryServices/RecoveryServices.Backup.Test/ScenarioTests/IaasVm/ItemTests.ps1

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,39 @@
1212
# limitations under the License.
1313
# ----------------------------------------------------------------------------------
1414

15+
function Test-AzureCrossZonalRestore
16+
{
17+
$location = "eastus"
18+
$resourceGroupName = "hiagarg"
19+
$vaultName = "hiaga-zrs-vault"
20+
$vmName = "VM;iaasvmcontainerv2;hiagarg;hiagaNZP"
21+
$saName = "hiagaeussa"
22+
$targetVMName = "czr-pstest-vm"
23+
$targetVNetName = "hiagaNZPVNet"
24+
$targetVNetRG = "hiagarg"
25+
$targetSubnetName = "custom"
26+
$recoveryPointId = "175071499837856" # latest vaultStandard recovery point
27+
28+
try
29+
{
30+
# Setup
31+
$vault = Get-AzRecoveryServicesVault -ResourceGroupName $resourceGroupName -Name $vaultName
32+
$item = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM `
33+
-VaultId $vault.ID -Name $vmName
34+
35+
$rp = Get-AzRecoveryServicesBackupRecoveryPoint -Item $item[0] -VaultId $vault.ID -RecoveryPointId $recoveryPointId
36+
37+
$restoreJobCZR = Restore-AzRecoveryServicesBackupItem -VaultId $vault.ID -VaultLocation $vault.Location `
38+
-RecoveryPoint $rp[0] -StorageAccountName $saName -StorageAccountResourceGroupName $vault.ResourceGroupName -TargetResourceGroupName $vault.ResourceGroupName -TargetVMName $targetVMName -TargetVNetName $targetVNetName -TargetVNetResourceGroup $targetVNetRG -TargetSubnetName $targetSubnetName -TargetZoneNumber 2 | Wait-AzRecoveryServicesBackupJob -VaultId $vault.ID
39+
40+
Assert-True { $restoreJobCZR.Status -eq "Completed" }
41+
}
42+
finally
43+
{
44+
Delete-VM $resourceGroupName $targetVMName
45+
}
46+
}
47+
1548
function Test-AzureMonitorAlerts
1649
{
1750
$location = "centraluseuap"

src/RecoveryServices/RecoveryServices.Backup.Test/SessionRecords/Microsoft.Azure.Commands.RecoveryServices.Backup.Test.ScenarioTests.ItemTests/TestAzureCrossZonalRestore.json

Lines changed: 3290 additions & 0 deletions
Large diffs are not rendered by default.

src/RecoveryServices/RecoveryServices.Backup/Cmdlets/Restore/RestoreAzureRMRecoveryServicesBackupItem.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ public override void ExecuteCmdlet()
416416

417417
ServiceClientModel.BackupResourceEncryptionConfigExtendedResource vaultEncryptionSettings = ServiceClientAdapter.GetVaultEncryptionConfig(resourceGroupName, vaultName);
418418

419-
if ((vaultEncryptionSettings.Properties.EncryptionAtRestType == "CustomerManaged") && rp.IsManagedVirtualMachine && !(rp.EncryptionEnabled) && !(RestoreToSecondaryRegion.IsPresent))
419+
if ((vaultEncryptionSettings.Properties.EncryptionAtRestType == "CustomerManaged") && rp.IsManagedVirtualMachine && !(rp.EncryptionEnabled))
420420
{
421421
providerParameters.Add(RestoreVMBackupItemParams.DiskEncryptionSetId, DiskEncryptionSetId);
422422
}

src/RecoveryServices/RecoveryServices/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added support for passing DiskEncryptionSetId for Cross region restore
2122
* Fixed the pagination bug in `Get-AzRecoveryServicesAsrProtectableItem` for the V2ARCM scenario.
2223
* Fixed `IncludeDiskId` property for `New-ASRReplicationProtectedItem` cmdlet of H2A
2324

src/RecoveryServices/RecoveryServices/help/Restore-AzRecoveryServicesBackupItem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ $restoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -Rehydr
303303

304304
Here we filter the recovery points present in the VaultArchive tier and trigger a restore with rehydration priority and rehydration duration.
305305

306-
### Example 10: CZR restore example
306+
### Example 10: Cross zonal restore for non-ZonePinned VM in a ZRS vault
307307

308308
```powershell
309309
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"

0 commit comments

Comments
 (0)