Skip to content

Commit 73e42d6

Browse files
Honoring UseManagedDisk input for HyperV to Azure scenario in site recovery service (#14128) (#14131)
* Honoring UseManagedDisk input for HyperV to Azure scenario in site recovery service * Update in changeLog * Update in help file * Minor fix in help file * Added test cases * NIT fixes for spaces * Addressed review comments Co-authored-by: vidyadharijami <[email protected]>
1 parent 3ecb37d commit 73e42d6

File tree

6 files changed

+1128
-2
lines changed

6 files changed

+1128
-2
lines changed

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/B2A/AsrB2ATests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,5 +204,22 @@ public void TestUpdateRPIWithAvZone()
204204
this.VaultSettingsFilePath +
205205
"\"");
206206
}
207+
208+
[Fact]
209+
[Trait(
210+
Category.AcceptanceType,
211+
Category.CheckIn)]
212+
public void TestCreateRPIWithManagedDisk()
213+
{
214+
this.VaultSettingsFilePath = System.IO.Path.Combine(
215+
System.AppDomain.CurrentDomain.BaseDirectory,
216+
"ScenarioTests", "B2A", "B2AInput", "B2A.VaultCredentials");
217+
this.RunPowerShellTest(
218+
_logger,
219+
Constants.NewModel,
220+
"Test-CreateRPIWithManagedDisk -vaultSettingsFilePath \"" +
221+
this.VaultSettingsFilePath +
222+
"\"");
223+
}
207224
}
208225
}

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/ScenarioTests/B2A/AsrB2ATests.ps1

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,4 +890,24 @@ function Test-UpdateRPIWithAvailabilityZone
890890
Set-AsrReplicationProtectedItem -InputObject $rpi -RecoveryAvailabilityZone $avZoneSet
891891
$rpi = Get-AsrReplicationProtectedItem -ProtectionContainer $pc -FriendlyName $VMFriendlyName
892892
Assert-NotNull($rpi.ProviderSpecificDetails.RecoveryAvailabilityZone)
893+
}
894+
895+
function Test-CreateRPIWithManagedDisk
896+
{
897+
param([string] $vaultSettingsFilePath)
898+
899+
# Import Azure RecoveryServices Vault Settings File
900+
Import-AzRecoveryServicesAsrVaultSettingsFile -Path $vaultSettingsFilePath
901+
$PrimaryFabricName = "H2ASite"
902+
$fabric = Get-AsrFabric -FriendlyName $PrimaryFabricName
903+
$pc = Get-ASRProtectionContainer -Fabric $fabric
904+
$pcm = Get-ASRProtectionContainerMapping -ProtectionContainer $pc
905+
$policyName ="b2apolicy"
906+
$policy = Get-AzRecoveryServicesAsrPolicy -Name $policyName
907+
$VMFriendlyName ="NestedDum1"
908+
$VM= Get-AsrProtectableItem -ProtectionContainer $pc -FriendlyName $VMFriendlyName
909+
$ResourceGroupId ="/subscriptions/b364ed8d-4279-4bf8-8fd1-56f8fa0ae05c/resourceGroups/h2arg"
910+
$LogStorageAccountId = "/subscriptions/b364ed8d-4279-4bf8-8fd1-56f8fa0ae05c/resourceGroups/h2arg/providers/Microsoft.Storage/storageAccounts/hrasa"
911+
$ppg = "/subscriptions/b364ed8d-4279-4bf8-8fd1-56f8fa0ae05c/resourceGroups/h2arg/providers/Microsoft.Compute/proximityPlacementGroups/ppgh2a"
912+
$EnableDRjob = New-AsrReplicationProtectedItem -ProtectableItem $VM -Name $VM.Name -ProtectionContainerMapping $pcm -RecoveryAzureStorageAccountId $LogStorageAccountId -OSDiskName $($VMFriendlyName+"disk") -OS Windows -RecoveryResourceGroupId $ResourceGroupId -RecoveryProximityPlacementGroupId $ppg -UseManagedDisk true
893913
}

src/RecoveryServices/RecoveryServices.SiteRecovery.Test/SessionRecords/RecoveryServices.SiteRecovery.Test.AsrB2ATests/TestCreateRPIWithManagedDisk.json

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

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,17 @@ public class NewAzureRmRecoveryServicesAsrReplicationProtectedItem : SiteRecover
306306
[ValidateNotNullOrEmpty]
307307
public string RecoveryAvailabilitySetId { get; set; }
308308

309+
/// <summary>
310+
/// Gets or sets if the Azure virtual machine that is created on failover should use managed disks.
311+
/// </summary>
312+
[Parameter]
313+
[ValidateNotNullOrEmpty]
314+
[ValidateSet(
315+
Constants.True,
316+
Constants.False)]
317+
[Parameter(ParameterSetName = ASRParameterSets.HyperVSiteToAzure)]
318+
public string UseManagedDisk { get; set; }
319+
309320
/// <summary>
310321
/// Gets or sets BootDiagnosticStorageAccountId.
311322
/// </summary>
@@ -592,6 +603,7 @@ private void EnterpriseAndHyperVToAzure(EnableProtectionInput input)
592603
: this.RecoveryVmName;
593604
providerSettings.TargetProximityPlacementGroupId = this.RecoveryProximityPlacementGroupId;
594605
providerSettings.TargetAvailabilityZone = this.RecoveryAvailabilityZone;
606+
providerSettings.UseManagedDisks = this.UseManagedDisk;
595607

596608
if (!string.IsNullOrEmpty(this.RecoveryAzureNetworkId))
597609
{

src/RecoveryServices/RecoveryServices/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* Added Zone Redundancy for Recovery Service Vaults.
2323
* Azure Site Recovery support for Proximity placement group for VMware to Azure and HyperV to Azure providers.
2424
* Azure Site Recovery support for Availability zone for VMware to Azure and HyperV to Azure providers.
25+
* Azure Site Recovery support for UseManagedDisk for HyperV to Azure provider
2526

2627
## Version 3.3.0
2728
* Added Cross Region Restore feature.

src/RecoveryServices/RecoveryServices/help/New-AzRecoveryServicesAsrReplicationProtectedItem.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ New-AzRecoveryServicesAsrReplicationProtectedItem [-HyperVToAzure] -ProtectableI
5858
-RecoveryAzureStorageAccountId <String> -OSDiskName <String> -OS <String> [-LogStorageAccountId <String>]
5959
[-IncludeDiskId <String[]>] [-RecoveryAzureNetworkId <String>] [-RecoveryAzureSubnetName <String>]
6060
-RecoveryResourceGroupId <String> [-RecoveryAvailabilityZone <String>]
61-
[-RecoveryProximityPlacementGroupId <String>] [-WaitForCompletion] [-DefaultProfile <IAzureContextContainer>]
62-
[-WhatIf] [-Confirm] [<CommonParameters>]
61+
[-RecoveryProximityPlacementGroupId <String>] [-UseManagedDisk <String>] [-WaitForCompletion]
62+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
6363
```
6464

6565
### AzureToAzure
@@ -685,6 +685,22 @@ Accept pipeline input: False
685685
Accept wildcard characters: False
686686
```
687687
688+
### -UseManagedDisk
689+
Specifies if the Azure virtual machine that is created on failover should use managed disks. It Accepts either True or False.
690+
691+
```yaml
692+
Type: System.String
693+
Parameter Sets: (All)
694+
Aliases:
695+
Accepted values: True, False
696+
697+
Required: False
698+
Position: Named
699+
Default value: None
700+
Accept pipeline input: False
701+
Accept wildcard characters: False
702+
```
703+
688704
### -VmmToVmm
689705
Switch parameter to specify the replicated item is a Hyper-V virtual machine that is being replicated between VMM managed Hyper-V sites.
690706

0 commit comments

Comments
 (0)