Skip to content

Commit 5498b82

Browse files
bashargBashar Gharaibeh
andauthored
Add Deep delete options for Disks and NICs (#15177)
* DeleteOptions for Disks and NetworkInterfaces * DeleteOption fixes * Upgrade to Microsoft.Azure.Management.Compute Version 47.0.0 * Updated help files * temporyr change to move Compute package to version 47 Co-authored-by: Bashar Gharaibeh <[email protected]>
1 parent 7307e5e commit 5498b82

File tree

22 files changed

+10003
-2941
lines changed

22 files changed

+10003
-2941
lines changed

src/Compute/Compute.Test/ScenarioTests/StrategiesVirtualMachineTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ public void TestSimpleNewVm()
3535
TestRunner.RunTestScript("Test-SimpleNewVm");
3636
}
3737

38+
[Fact]
39+
[Trait(Category.AcceptanceType, Category.CheckIn)]
40+
public void TestSimpleNewVmWithDeleteOptions()
41+
{
42+
TestRunner.RunTestScript("Test-SimpleNewVmWithDeleteOptions");
43+
}
44+
3845
[Fact]
3946
[Trait(Category.AcceptanceType, Category.CheckIn)]
4047
public void TestSimpleNewVmFromSIGImage()

src/Compute/Compute.Test/ScenarioTests/StrategiesVirtualMachineTests.ps1

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,40 @@ function Test-SimpleNewVm
4646
}
4747
}
4848

49+
<#
50+
.SYNOPSIS
51+
Test Simple Paremeter Set for New Vm
52+
#>
53+
function Test-SimpleNewVmWithDeleteOptions
54+
{
55+
# Setup
56+
$vmname = Get-ResourceName
57+
58+
try
59+
{
60+
$username = "admin01"
61+
$password = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force
62+
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
63+
[string]$domainNameLabel = "$vmname-$vmname".tolower();
64+
65+
# Common
66+
$x = New-AzVM -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel -NetworkInterfaceDeleteOption "Delete" -OSDiskDeleteOption "Detach" -DataDiskSizeInGb 32 -DataDiskDeleteOption "Delete"
67+
68+
Assert-AreEqual $vmname $x.Name;
69+
Assert-Null $x.Identity
70+
Assert-False { $x.AdditionalCapabilities.UltraSSDEnabled };
71+
72+
Assert-AreEqual $x.NetworkProfile.NetworkInterfaces[0].DeleteOption "Delete"
73+
Assert-AreEqual $x.StorageProfile.OSDisk.DeleteOption "Detach"
74+
75+
}
76+
finally
77+
{
78+
# Cleanup
79+
Clean-ResourceGroup $vmname
80+
}
81+
}
82+
4983
<#
5084
.SYNOPSIS
5185
Test Simple Paremeter Set for New Vm

src/Compute/Compute.Test/ScenarioTests/VirtualMachineNetworkInterfaceTests.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,10 +388,11 @@ function Test-AddNetworkInterface
388388

389389
$nicList = Get-AzNetworkInterface -ResourceGroupName $rgname;
390390
$nicList[0].Primary = $true;
391-
$p = Add-AzVMNetworkInterface -VM $p -NetworkInterface $nicList;
391+
$p = Add-AzVMNetworkInterface -VM $p -NetworkInterface $nicList -DeleteOption "Detach";
392392
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
393393
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicList[0].Id;
394394
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Primary $true;
395+
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].DeleteOption "Detach";
395396

396397
# Storage Account (SA)
397398
$stoname = 'sto' + $rgname;
@@ -453,6 +454,7 @@ function Test-AddNetworkInterface
453454
Assert-AreEqual $vm1.Name $vmname;
454455
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces.Count 1;
455456
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].Id $nicId;
457+
Assert-AreEqual $vm1.NetworkProfile.NetworkInterfaces[0].DeleteOption "Detach";
456458
}
457459
finally
458460
{
@@ -840,3 +842,5 @@ function Test-VMNicWithAcceleratedNetworkingValidations
840842
Clean-ResourceGroup $rgname
841843
}
842844
}
845+
846+

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ public void TestVirtualMachineManagedDiskConversion()
249249
TestRunner.RunTestScript("Test-VirtualMachineManagedDiskConversion");
250250
}
251251

252+
[Fact]
253+
[Trait(Category.AcceptanceType, Category.CheckIn)]
254+
public void TestVirtualMachineDiskDeleteOption()
255+
{
256+
TestRunner.RunTestScript("Test-VirtualMachineDiskDeleteOption");
257+
}
258+
252259
[Fact]
253260
[Trait(Category.AcceptanceType, Category.CheckIn)]
254261
public void TestVirtualMachinePerformanceMaintenance()

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,6 +3328,153 @@ function Test-VirtualMachineManagedDiskConversion
33283328
}
33293329
}
33303330

3331+
<#
3332+
.SYNOPSIS
3333+
Test Virtual Machine managed disk delete option
3334+
#>
3335+
function Test-VirtualMachineDiskDeleteOption
3336+
{
3337+
# Setup
3338+
$rgname = Get-ComputeTestResourceName
3339+
3340+
try
3341+
{
3342+
# Common
3343+
if ($loc -eq $null)
3344+
{
3345+
$loc = Get-ComputeVMLocation;
3346+
}
3347+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
3348+
3349+
# VM Profile & Hardware
3350+
$vmsize = 'Standard_A4';
3351+
$vmname = 'vm' + $rgname;
3352+
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize;
3353+
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
3354+
3355+
# NRP
3356+
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
3357+
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
3358+
$subnetId = $vnet.Subnets[0].Id;
3359+
$pubip = New-AzPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
3360+
$pubipId = $pubip.Id;
3361+
$nic = New-AzNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
3362+
$nicId = $nic.Id;
3363+
3364+
$p = Add-AzVMNetworkInterface -VM $p -Id $nicId;
3365+
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
3366+
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
3367+
3368+
# Adding the same Nic but not set it Primary
3369+
$p = Add-AzVMNetworkInterface -VM $p -Id $nicId -Primary;
3370+
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces.Count 1;
3371+
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Id $nicId;
3372+
Assert-AreEqual $p.NetworkProfile.NetworkInterfaces[0].Primary $true;
3373+
3374+
# Storage Account (SA)
3375+
$stoname = 'sto' + $rgname;
3376+
$stotype = 'Standard_GRS';
3377+
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
3378+
$stoaccount = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname;
3379+
3380+
$osDiskName = 'osDisk';
3381+
$osDiskCaching = 'ReadWrite';
3382+
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
3383+
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
3384+
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
3385+
$dataDiskVhdUri3 = "https://$stoname.blob.core.windows.net/test/data3.vhd";
3386+
3387+
$p = Set-AzVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage -DeleteOption "Delete";
3388+
3389+
$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty -DeleteOption "Delete";
3390+
$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty -DeleteOption "Detach";
3391+
$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk3' -Caching 'ReadOnly' -DiskSizeInGB 12 -Lun 3 -VhdUri $dataDiskVhdUri3 -CreateOption Empty;
3392+
$p = Remove-AzVMDataDisk -VM $p -Name 'testDataDisk3';
3393+
3394+
Assert-AreEqual $p.StorageProfile.OSDisk.Caching $osDiskCaching;
3395+
Assert-AreEqual $p.StorageProfile.OSDisk.Name $osDiskName;
3396+
Assert-AreEqual $p.StorageProfile.OSDisk.Vhd.Uri $osDiskVhdUri;
3397+
Assert-AreEqual $p.StorageProfile.OSDisk.DeleteOption "Delete";
3398+
Assert-AreEqual $p.StorageProfile.DataDisks.Count 2;
3399+
Assert-AreEqual $p.StorageProfile.DataDisks[0].Caching 'ReadOnly';
3400+
Assert-AreEqual $p.StorageProfile.DataDisks[0].DiskSizeGB 10;
3401+
Assert-AreEqual $p.StorageProfile.DataDisks[0].Lun 1;
3402+
Assert-AreEqual $p.StorageProfile.DataDisks[0].Vhd.Uri $dataDiskVhdUri1;
3403+
Assert-AreEqual $p.StorageProfile.DataDisks[0].DeleteOption "Delete";
3404+
Assert-AreEqual $p.StorageProfile.DataDisks[1].Caching 'ReadOnly';
3405+
Assert-AreEqual $p.StorageProfile.DataDisks[1].DiskSizeGB 11;
3406+
Assert-AreEqual $p.StorageProfile.DataDisks[1].Lun 2;
3407+
Assert-AreEqual $p.StorageProfile.DataDisks[1].Vhd.Uri $dataDiskVhdUri2;
3408+
Assert-AreEqual $p.StorageProfile.DataDisks[1].DeleteOption "Detach";
3409+
3410+
# OS & Image
3411+
$user = "Foo12";
3412+
$password = $PLACEHOLDER;
3413+
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
3414+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
3415+
$computerName = 'test';
3416+
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
3417+
3418+
# $p.StorageProfile.OSDisk = $null;
3419+
$p = Set-AzVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
3420+
3421+
$imgRef = Get-DefaultCRPImage -loc $loc;
3422+
$p = ($imgRef | Set-AzVMSourceImage -VM $p);
3423+
3424+
Assert-AreEqual $p.OSProfile.AdminUsername $user;
3425+
Assert-AreEqual $p.OSProfile.ComputerName $computerName;
3426+
Assert-AreEqual $p.OSProfile.AdminPassword $password;
3427+
3428+
Assert-AreEqual $p.StorageProfile.ImageReference.Offer $imgRef.Offer;
3429+
Assert-AreEqual $p.StorageProfile.ImageReference.Publisher $imgRef.PublisherName;
3430+
Assert-AreEqual $p.StorageProfile.ImageReference.Sku $imgRef.Skus;
3431+
Assert-AreEqual $p.StorageProfile.ImageReference.Version $imgRef.Version;
3432+
3433+
# Virtual Machine
3434+
New-AzVM -ResourceGroupName $rgname -Location $loc -VM $p;
3435+
3436+
$vm2 = Get-AzVM -Name $vmname -ResourceGroupName $rgname;
3437+
3438+
Assert-AreEqual $vm2.NetworkProfile.NetworkInterfaces.Count 1;
3439+
Assert-AreEqual $vm2.NetworkProfile.NetworkInterfaces[0].Id $nicId;
3440+
Assert-AreEqual $vm2.StorageProfile.DataDisks.Count 2;
3441+
3442+
Assert-AreEqual $vm2.OSProfile.AdminUsername $user;
3443+
Assert-AreEqual $vm2.OSProfile.ComputerName $computerName;
3444+
Assert-AreEqual $vm2.HardwareProfile.VmSize $vmsize;
3445+
Assert-NotNull $vm2.Location;
3446+
3447+
Assert-Null $vm2.StorageProfile.OSDisk.ManagedDisk
3448+
Assert-Null $vm2.StorageProfile.DataDisks[0].ManagedDisk
3449+
Assert-Null $vm2.StorageProfile.DataDisks[1].ManagedDisk
3450+
3451+
# Deallocate the VM before conversion
3452+
Stop-AzVM -ResourceGroupName $rgname -Name $vmname -Force
3453+
3454+
# Convert VM to managed disks
3455+
$job = ConvertTo-AzVMManagedDisk -ResourceGroupName $rgname -VMName $vmname -AsJob;
3456+
$result = $job | Wait-Job;
3457+
Assert-AreEqual "Completed" $result.State;
3458+
3459+
$vm2 = Get-AzVM -Name $vmname -ResourceGroupName $rgname;
3460+
3461+
Assert-NotNull $vm2.StorageProfile.OSDisk.ManagedDisk
3462+
Assert-AreEqual $vm2.StorageProfile.OSDisk.DeleteOption "Delete"
3463+
Assert-NotNull $vm2.StorageProfile.DataDisks[0].ManagedDisk
3464+
Assert-AreEqual $vm2.StorageProfile.DataDisks[0].DeleteOption "Delete"
3465+
Assert-NotNull $vm2.StorageProfile.DataDisks[1].ManagedDisk
3466+
Assert-AreEqual $vm2.StorageProfile.DataDisks[1].DeleteOption "Detach"
3467+
3468+
# Remove
3469+
Remove-AzVM -ResourceGroupName $rgname -Name $vmname -Force;
3470+
}
3471+
finally
3472+
{
3473+
# Cleanup
3474+
Clean-ResourceGroup $rgname
3475+
}
3476+
}
3477+
33313478
<#
33323479
.SYNOPSIS
33333480
Test Virtual Machine Performance Maintenance

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.StrategiesVirtualMachineTests/TestSimpleNewVmWithDeleteOptions.json

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

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineNetworkInterfaceTests/TestAddNetworkInterface.json

Lines changed: 1766 additions & 2898 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestVirtualMachineDiskDeleteOption.json

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

src/Compute/Compute/Generated/VirtualMachineScaleSet/Config/AddAzureRmVmssNetworkInterfaceConfigurationCommand.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public partial class AddAzureRmVmssNetworkInterfaceConfigurationCommand : Micros
8484
[Alias("DnsServer")]
8585
public string[] DnsSettingsDnsServer { get; set; }
8686

87+
[Parameter(
88+
Mandatory = false,
89+
ValueFromPipelineByPropertyName = true)]
90+
public string NetworkApiVersion { get; set; }
91+
8792
protected override void ProcessRecord()
8893
{
8994
if (ShouldProcess("VirtualMachineScaleSet", "Add"))
@@ -106,6 +111,18 @@ private void Run()
106111
this.VirtualMachineScaleSet.VirtualMachineProfile.NetworkProfile = new VirtualMachineScaleSetNetworkProfile();
107112
}
108113

114+
if (this.IsParameterBound(c => c.NetworkApiVersion))
115+
{
116+
this.VirtualMachineScaleSet.VirtualMachineProfile.NetworkProfile.NetworkApiVersion = this.NetworkApiVersion;
117+
}
118+
else
119+
{
120+
// If networkApiVersion is not specified, reuse the existing one in network profile if not null,
121+
// else use default version
122+
this.VirtualMachineScaleSet.VirtualMachineProfile.NetworkProfile.NetworkApiVersion = this.VirtualMachineScaleSet.VirtualMachineProfile.NetworkProfile.NetworkApiVersion
123+
?? Microsoft.Azure.Management.Compute.Models.NetworkApiVersion.TwoZeroTwoZeroHyphenMinusOneOneHyphenMinusZeroOne;
124+
}
125+
109126
// NetworkInterfaceConfigurations
110127
if (this.VirtualMachineScaleSet.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations == null)
111128
{

src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetCreateOrUpdateMethod.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,26 @@ public override void ExecuteCmdlet()
6161
WriteWarning("You are deploying VMSS pinned to a specific image version from Azure Marketplace. \n" +
6262
"Consider using \"latest\" as the image version. This allows VMSS to auto upgrade when a newer version is available.");
6363
}
64+
65+
if (parameters?.OrchestrationMode == OrchestrationMode.Flexible)
66+
{
67+
if (parameters?.VirtualMachineProfile?.NetworkProfile?.NetworkInterfaceConfigurations != null)
68+
{
69+
foreach (var nicConfig in parameters.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations)
70+
{
71+
if (nicConfig.IpConfigurations != null)
72+
{
73+
foreach (var ipConfig in nicConfig.IpConfigurations)
74+
{
75+
ipConfig.LoadBalancerInboundNatPools = null;
76+
}
77+
}
78+
}
79+
}
80+
81+
parameters.UpgradePolicy = null;
82+
}
83+
6484
var result = VirtualMachineScaleSetsClient.CreateOrUpdate(resourceGroupName, vmScaleSetName, parameters);
6585
var psObject = new PSVirtualMachineScaleSet();
6686
ComputeAutomationAutoMapperProfile.Mapper.Map<VirtualMachineScaleSet, PSVirtualMachineScaleSet>(result, psObject);

src/Compute/Compute/Strategies/ComputeRp/DataDiskStrategy.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static IList<T> CreateDataDisks<T>(
3333

3434
public static IList<DataDisk> CreateDataDisks(
3535
IEnumerable<int> imageDataDiskLuns,
36-
IEnumerable<int> dataDiskSizes)
36+
IEnumerable<int> dataDiskSizes,
37+
string deleteOption = null)
3738
=> CreateDataDisks(
3839
imageDataDiskLuns,
3940
dataDiskSizes,
@@ -42,6 +43,7 @@ public static IList<DataDisk> CreateDataDisks(
4243
CreateOption = createOption,
4344
Lun = lun,
4445
DiskSizeGB = size,
46+
DeleteOption = deleteOption
4547
});
4648

4749
public static IList<VirtualMachineScaleSetDataDisk> CreateVmssDataDisks(

src/Compute/Compute/Strategies/ComputeRp/NetworkInterfaceReferenceStrategy.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Microsoft.Azure.Commands.Compute.Strategies.ComputeRp
2121
static class NetworkInterfaceReferenceStrategy
2222
{
2323
public static NetworkInterfaceReference GetReference(
24-
this IEngine engine, ResourceConfig<NetworkInterface> networkInterface)
25-
=> new NetworkInterfaceReference { Id = engine.GetId(networkInterface) };
24+
this IEngine engine, ResourceConfig<NetworkInterface> networkInterface, string deleteOption = null)
25+
=> new NetworkInterfaceReference { Id = engine.GetId(networkInterface), DeleteOption = deleteOption };
2626
}
2727
}

src/Compute/Compute/Strategies/ComputeRp/VirtualMachineStrategy.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
5959
string priority,
6060
string evictionPolicy,
6161
double? maxPrice,
62-
bool encryptionAtHostPresent)
62+
bool encryptionAtHostPresent,
63+
string networkInterfaceDeleteOption = null,
64+
string osDiskDeleteOption = null,
65+
string dataDiskDeleteOption = null)
6366

6467
=> Strategy.CreateResourceConfig(
6568
resourceGroup: resourceGroup,
@@ -79,7 +82,7 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
7982
{
8083
NetworkInterfaces = new[]
8184
{
82-
engine.GetReference(networkInterface)
85+
engine.GetReference(networkInterface, networkInterfaceDeleteOption)
8386
}
8487
},
8588
HardwareProfile = new HardwareProfile
@@ -90,7 +93,7 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
9093
{
9194
ImageReference = imageAndOsType?.Image,
9295
DataDisks = DataDiskStrategy.CreateDataDisks(
93-
imageAndOsType?.DataDiskLuns, dataDisks)
96+
imageAndOsType?.DataDiskLuns, dataDisks, dataDiskDeleteOption)
9497
},
9598
AvailabilitySet = engine.GetReference(availabilitySet),
9699
Zones = zones,
@@ -124,7 +127,10 @@ public static ResourceConfig<VirtualMachine> CreateVirtualMachineConfig(
124127
string priority,
125128
string evictionPolicy,
126129
double? maxPrice,
127-
bool encryptionAtHostPresent
130+
bool encryptionAtHostPresent,
131+
string networkInterfaceDeleteOption = null,
132+
string osDiskDeleteOption = null,
133+
string dataDiskDeleteOption = null
128134
)
129135
=> Strategy.CreateResourceConfig(
130136
resourceGroup: resourceGroup,
@@ -135,7 +141,7 @@ bool encryptionAtHostPresent
135141
{
136142
NetworkInterfaces = new[]
137143
{
138-
engine.GetReference(networkInterface)
144+
engine.GetReference(networkInterface, networkInterfaceDeleteOption)
139145
}
140146
},
141147
HardwareProfile = new HardwareProfile
@@ -150,8 +156,9 @@ bool encryptionAtHostPresent
150156
CreateOption = DiskCreateOptionTypes.Attach,
151157
OsType = osType,
152158
ManagedDisk = engine.GetReference(disk, ultraSSDEnabled ? StorageAccountTypes.UltraSSDLRS : StorageAccountTypes.PremiumLRS),
159+
DeleteOption = osDiskDeleteOption
153160
},
154-
DataDisks = DataDiskStrategy.CreateDataDisks(null, dataDisks)
161+
DataDisks = DataDiskStrategy.CreateDataDisks(null, dataDisks, dataDiskDeleteOption)
155162
},
156163
Identity = identity,
157164
AvailabilitySet = engine.GetReference(availabilitySet),

0 commit comments

Comments
 (0)