Skip to content

[RecoveryServices.Backup] Added support for passing DiskEncryptionSetId for Cross region restore #20295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ Please contact Microsoft for further assistance.</value>
<value>ResourceGuardMapping not found</value>
</data>
<data name="DisableWithRetainBackupNotCrititcal" xml:space="preserve">
<value>Invalid parameter Token: Stop protection with retain backup data is not MUA protected</value>
<value>Invalid parameter Token. Stop protection with retain backup data is not MUA protected</value>
</data>
<data name="CRRNotSupportedWIthCSR" xml:space="preserve">
<value>Cross region restore is not supported along with cross subscription restore, please try passing either RestoreToSecondaryRegion or TargetSubscriptionId parameter but not both</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,18 @@ public void TestAzureMonitorAlerts()
$"Import-Module {_IaasVmtestModule.AsAbsoluteLocation()}",
"Test-AzureMonitorAlerts"
);
}
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(TestConstants.Workload, TestConstants.AzureVM)]
public void TestAzureCrossZonalRestore()
{
TestRunner.RunTestScript(
$"Import-Module {_IaasVmcommonModule.AsAbsoluteLocation()}",
$"Import-Module {_IaasVmtestModule.AsAbsoluteLocation()}",
"Test-AzureCrossZonalRestore"
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,39 @@
# limitations under the License.
# ----------------------------------------------------------------------------------

function Test-AzureCrossZonalRestore
{
$location = "eastus"
$resourceGroupName = "hiagarg"
$vaultName = "hiaga-zrs-vault"
$vmName = "VM;iaasvmcontainerv2;hiagarg;hiagaNZP"
$saName = "hiagaeussa"
$targetVMName = "czr-pstest-vm"
$targetVNetName = "hiagaNZPVNet"
$targetVNetRG = "hiagarg"
$targetSubnetName = "custom"
$recoveryPointId = "175071499837856" # latest vaultStandard recovery point

try
{
# Setup
$vault = Get-AzRecoveryServicesVault -ResourceGroupName $resourceGroupName -Name $vaultName
$item = Get-AzRecoveryServicesBackupItem -BackupManagementType AzureVM -WorkloadType AzureVM `
-VaultId $vault.ID -Name $vmName

$rp = Get-AzRecoveryServicesBackupRecoveryPoint -Item $item[0] -VaultId $vault.ID -RecoveryPointId $recoveryPointId

$restoreJobCZR = Restore-AzRecoveryServicesBackupItem -VaultId $vault.ID -VaultLocation $vault.Location `
-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

Assert-True { $restoreJobCZR.Status -eq "Completed" }
}
finally
{
Delete-VM $resourceGroupName $targetVMName
}
}

function Test-AzureMonitorAlerts
{
$location = "centraluseuap"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public override void ExecuteCmdlet()

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

if ((vaultEncryptionSettings.Properties.EncryptionAtRestType == "CustomerManaged") && rp.IsManagedVirtualMachine && !(rp.EncryptionEnabled) && !(RestoreToSecondaryRegion.IsPresent))
if ((vaultEncryptionSettings.Properties.EncryptionAtRestType == "CustomerManaged") && rp.IsManagedVirtualMachine && !(rp.EncryptionEnabled))
{
providerParameters.Add(RestoreVMBackupItemParams.DiskEncryptionSetId, DiskEncryptionSetId);
}
Expand Down
1 change: 1 addition & 0 deletions src/RecoveryServices/RecoveryServices/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Added support for passing DiskEncryptionSetId for Cross region restore
* Fixed the pagination bug in `Get-AzRecoveryServicesAsrProtectableItem` for the V2ARCM scenario.
* Fixed `IncludeDiskId` property for `New-ASRReplicationProtectedItem` cmdlet of H2A

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ $restoreJob = Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -Rehydr

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

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

```powershell
$vault = Get-AzRecoveryServicesVault -ResourceGroupName "resourceGroup" -Name "vaultName"
Expand Down