Skip to content

Commit 6631b4e

Browse files
hyonholeeerich-wang
authored andcommitted
1. Add 'Spot' to the Priority argument completer in New-AzVM, New-AzVMConfig, New-AzVmss (Azure#10541)
2. Add Reapply parameter to Set-AzVM 3. New-AzVM with cross tenant gallery image. 4. AutomaticRepairs feature: - Add EnableAutomaticRepair, AutomaticRepairGracePeriod, and AutomaticRepairMaxInstanceRepairsPercent parameters to New-AzVmssConfig, Update-AzVmss 5. DiskIOPSReadWrite and DiskMBpsReadWrite parameters to Add-AzVmssDataDisk 6. Update SourceImageId parameter of New-AzGalleryImageVersion to optional 7. Add OSDiskImage and DataDiskImage parameters to New-AzGalleryImageVersion 8. Add HyperVGeneration parameter to New-AzGalleryImageDefinition
1 parent a385cd6 commit 6631b4e

File tree

34 files changed

+19219
-2743
lines changed

34 files changed

+19219
-2743
lines changed

src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,12 @@ public void GalleryImageVersion()
4444
{
4545
TestRunner.RunTestScript("Test-GalleryImageVersion");
4646
}
47+
48+
[Fact]
49+
[Trait(Category.AcceptanceType, Category.CheckIn)]
50+
public void TestGalleryImageVersionDiskImage()
51+
{
52+
TestRunner.RunTestScript("Test-GalleryImageVersionDiskImage");
53+
}
4754
}
4855
}

src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1

Lines changed: 137 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ function Verify-GalleryImageDefinition
3333
[string] $publisherName, [string] $offerName, [string] $skuName,
3434
[int] $minVCPU, [int] $maxVCPU, [int] $minMemory, [int] $maxMemory,
3535
[string] $disallowedDiskType,
36-
[string] $purchasePlanName, [string] $purchasePlanPublisher, [string] $purchasePlanProduct)
36+
[string] $purchasePlanName, [string] $purchasePlanPublisher, [string] $purchasePlanProduct,
37+
[string] $hyperVGeneration)
3738

3839
Assert-AreEqual $rgname $imageDefinition.ResourceGroupName;
3940
Assert-AreEqual $imageDefinitionName $imageDefinition.Name;
@@ -62,20 +63,30 @@ function Verify-GalleryImageDefinition
6263
Assert-AreEqual $purchasePlanName $imageDefinition.PurchasePlan.Name;
6364
Assert-AreEqual $purchasePlanPublisher $imageDefinition.PurchasePlan.Publisher;
6465
Assert-AreEqual $purchasePlanProduct $imageDefinition.PurchasePlan.Product;
66+
67+
if (-not [string]::IsNullOrEmpty($hyperVGeneration))
68+
{
69+
Assert-AreEqual $hyperVGeneration $imageDefinition.HyperVGeneration;
70+
}
6571
}
6672

6773
function Verify-GalleryImageVersion
6874
{
6975
param($imageVersion, [string] $rgname, [string] $imageVersionName, [string] $loc,
70-
[string] $sourceImageId, [int] $replicaCount, $endOfLifeDate, $targetRegions)
76+
[string] $sourceImageId, [int] $replicaCount, $endOfLifeDate, $targetRegions,
77+
$osDiskImage, $dataDiskImages)
7178

7279
Assert-AreEqual $rgname $imageVersion.ResourceGroupName;
7380
Assert-AreEqual $imageVersionName $imageVersion.Name;
7481
Assert-AreEqual $loc $imageVersion.Location;
7582
Assert-AreEqual "Microsoft.Compute/galleries/images/versions" $imageVersion.Type;
7683
Assert-NotNull $imageVersion.Id;
7784

78-
Assert-AreEqual $sourceImageId $imageVersion.StorageProfile.Source.Id;
85+
if (-not [string]::IsNullOrEmpty($sourceImageId))
86+
{
87+
Assert-AreEqual $sourceImageId $imageVersion.StorageProfile.Source.Id;
88+
}
89+
7990
Assert-AreEqual $replicaCount $imageVersion.PublishingProfile.ReplicaCount;
8091
Assert-False { $imageVersion.PublishingProfile.ExcludeFromLatest };
8192

@@ -95,6 +106,17 @@ function Verify-GalleryImageVersion
95106
Assert-AreEqual $targetRegions[$i].ReplicaCount $imageVersion.PublishingProfile.TargetRegions[$i].RegionalReplicaCount;
96107
}
97108
}
109+
110+
if ($osDiskImage -ne $null)
111+
{
112+
Assert-AreEqual $osDiskImage.Source.Id $imageVersion.StorageProfile.OSDiskImage.Source.Id;
113+
}
114+
115+
for ($i = 0; $i -lt $dataDiskImages.Count; ++$i)
116+
{
117+
Assert-AreEqual $dataDiskImages[$i].Source.Id $imageVersion.StorageProfile.DataDiskImages[$i].Source.Id;
118+
Assert-AreEqual $dataDiskImages[$i].Lun $imageVersion.StorageProfile.DataDiskImages[$i].Lun;
119+
}
98120
}
99121

100122
<#
@@ -574,3 +596,115 @@ function Test-GalleryImageVersion
574596
Clean-ResourceGroup $rgname
575597
}
576598
}
599+
600+
<#
601+
.SYNOPSIS
602+
Testing gallery image version with disk image parameters
603+
#>
604+
function Test-GalleryImageVersionDiskImage
605+
{
606+
# Setup
607+
$rgname = Get-ComputeTestResourceName;
608+
$galleryName = 'gallery' + $rgname;
609+
$galleryImageName = 'galleryimage' + $rgname;
610+
$galleryImageVersionName = 'imageversion' + $rgname;
611+
612+
try
613+
{
614+
# Common
615+
[string]$loc = Get-ComputeVMLocation;
616+
$loc = $loc.Replace(' ', '');
617+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
618+
$description1 = "Original Description";
619+
620+
# Gallery
621+
New-AzGallery -ResourceGroupName $rgname -Name $galleryName -Description $description1 -Location $loc;
622+
623+
$gallery = Get-AzGallery -ResourceGroupName $rgname -Name $galleryName;
624+
Verify-Gallery $gallery $rgname $galleryName $loc $description1;
625+
$output = $gallery | Out-String;
626+
627+
# Gallery Image Definition
628+
$publisherName = "galleryPublisher20180927";
629+
$offerName = "galleryOffer20180927";
630+
$skuName = "gallerySku20180927";
631+
$eula = "eula";
632+
$privacyStatementUri = "https://www.microsoft.com";
633+
$releaseNoteUri = "https://www.microsoft.com";
634+
$disallowedDiskTypes = "Premium_LRS";
635+
$endOfLifeDate = [DateTime]::ParseExact('12 07 2025 18 02', 'HH mm yyyy dd MM', $null);
636+
$minMemory = 1;
637+
$maxMemory = 100;
638+
$minVCPU = 2;
639+
$maxVCPU = 32;
640+
$purchasePlanName = "purchasePlanName";
641+
$purchasePlanProduct = "purchasePlanProduct";
642+
$purchasePlanPublisher = "";
643+
$osState = "Generalized";
644+
$osType = "Windows";
645+
646+
New-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $galleryImageName `
647+
-Location $loc -Publisher $publisherName -Offer $offerName -Sku $skuName `
648+
-OsState $osState -OsType $osType `
649+
-Description $description1 -Eula $eula `
650+
-PrivacyStatementUri $privacyStatementUri -ReleaseNoteUri $releaseNoteUri `
651+
-DisallowedDiskType $disallowedDiskTypes -EndOfLifeDate $endOfLifeDate `
652+
-MinimumMemory $minMemory -MaximumMemory $maxMemory `
653+
-MinimumVCPU $minVCPU -MaximumVCPU $maxVCPU `
654+
-PurchasePlanName $purchasePlanName `
655+
-PurchasePlanProduct $purchasePlanProduct `
656+
-PurchasePlanPublisher $purchasePlanPublisher `
657+
-HyperVGeneration 'V1';
658+
659+
$definition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $galleryImageName;
660+
$output = $definition | Out-String;
661+
Verify-GalleryImageDefinition $definition $rgname $galleryImageName $loc $description1 `
662+
$eula $privacyStatementUri $releaseNoteUri `
663+
$osType $osState $endOfLifeDate `
664+
$publisherName $offerName $skuName `
665+
$minVCPU $maxVCPU $minMemory $maxMemory `
666+
$disallowedDiskTypes `
667+
$purchasePlanName $purchasePlanPublisher $purchasePlanProduct 'V1';
668+
669+
# Gallery Image Version
670+
$galleryImageVersionName = "1.0.0";
671+
672+
$snapshotname1 = 'ossnapshot' + $rgname;
673+
$snapshotconfig = New-AzSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty -HyperVGeneration "V1";
674+
$snapshot1 = New-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname1 -Snapshot $snapshotconfig
675+
676+
$snapshotname2 = 'data1snapshot' + $rgname;
677+
$snapshotconfig = New-AzSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty -HyperVGeneration "V1";
678+
$snapshot2 = New-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname2 -Snapshot $snapshotconfig
679+
680+
$snapshotname3 = 'data2snapshot' + $rgname;
681+
$snapshotconfig = New-AzSnapshotConfig -Location $loc -DiskSizeGB 5 -AccountType Standard_LRS -OsType Windows -CreateOption Empty -HyperVGeneration "V1";
682+
$snapshot3 = New-AzSnapshot -ResourceGroupName $rgname -SnapshotName $snapshotname3 -Snapshot $snapshotconfig
683+
684+
685+
$targetRegions = @(@{Name='South Central US';ReplicaCount=1;StorageAccountType='Standard_LRS'},@{Name='East US';ReplicaCount=2},@{Name='Central US'});
686+
$tag = @{test1 = "testval1"; test2 = "testval2" };
687+
688+
$osDiskImage = @{Source = @{Id="$($snapshot1.Id)"}}
689+
$dataDiskImage1 = @{Source = @{Id="$($snapshot2.Id)"};Lun=1}
690+
$dataDiskImage2 = @{Source = @{Id="$($snapshot3.Id)"};Lun=2}
691+
692+
New-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
693+
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName `
694+
-Location $loc -ReplicaCount 1 `
695+
-PublishingProfileEndOfLifeDate $endOfLifeDate `
696+
-StorageAccountType Standard_LRS `
697+
-TargetRegion $targetRegions `
698+
-OSDiskImage $osDiskImage -DataDiskImage $dataDiskImage1,$dataDiskImage2;
699+
700+
$version = Get-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName;
701+
702+
Verify-GalleryImageVersion $version $rgname $galleryImageVersionName $loc `
703+
$null 1 $endOfLifeDate $targetRegions $osDiskImage @($dataDiskImage1, $dataDiskImage2)
704+
}
705+
finally
706+
{
707+
# Cleanup
708+
Clean-ResourceGroup $rgname
709+
}
710+
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,12 @@ public void TestSimpleNewVmBilling()
176176
{
177177
TestRunner.RunTestScript("Test-SimpleNewVmBilling");
178178
}
179+
180+
[Fact]
181+
[Trait(Category.AcceptanceType, Category.CheckIn)]
182+
public void TestSimpleGalleryCrossTenant()
183+
{
184+
TestRunner.RunTestScript("Test-SimpleGalleryCrossTenant");
185+
}
179186
}
180187
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,3 +600,39 @@ function Test-SimpleNewVmBilling
600600
Clean-ResourceGroup $vmname
601601
}
602602
}
603+
604+
<#
605+
.SYNOPSIS
606+
Testing creating VM with a shared gallery image from a different subscription.
607+
#>
608+
function Test-SimpleGalleryCrossTenant
609+
{
610+
# Setup
611+
# In order to record this test, please use another subscription to create a gallery image and share the image to the test subscription. And then set the gallery image id here.
612+
$imageId = "/subscriptions/97f78232-382b-46a7-8a72-964d692c4f3f/resourceGroups/xwRg/providers/Microsoft.Compute/galleries/galleryForCirrus/images/xwGalleryImageForCirrusWindows/versions/1.0.0";
613+
614+
$vmname = Get-ComputeTestResourceName;
615+
616+
try
617+
{
618+
# Common
619+
$loc = Get-ComputeVMLocation;
620+
621+
# OS & Image
622+
$user = "Foo12";
623+
$password = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force;
624+
$cred = New-Object System.Management.Automation.PSCredential ($user, $password);
625+
[string]$domainNameLabel = "$vmname-$vmname".tolower();
626+
627+
# Virtual Machine
628+
New-AzVM -Name $vmname -Location $loc -Credential $cred -DomainNameLabel $domainNameLabel -ImageName $imageId
629+
630+
$vm = Get-AzVM -ResourceGroupName $vmname -Name $vmname;
631+
Assert-AreEqual $imageId $vm.StorageProfile.ImageReference.Id;
632+
}
633+
finally
634+
{
635+
# Cleanup
636+
Clean-ResourceGroup $vmname
637+
}
638+
}

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetProfileTests.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ function Test-VirtualMachineScaleSetProfile
6262
| Set-AzVmssOSProfile -ComputerNamePrefix $computePrefix -AdminUsername $adminUsername -AdminPassword $adminPassword `
6363
| Set-AzVmssStorageProfile -OsDiskCreateOption $createOption -OsDiskCaching $osCaching `
6464
-ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion $imgRef.Version -ImageReferencePublisher $imgRef.PublisherName `
65-
| Add-AzVmssExtension -Name $extname -Publisher $publisher -Type $exttype -TypeHandlerVersion $extver -AutoUpgradeMinorVersion $true;
65+
| Add-AzVmssExtension -Name $extname -Publisher $publisher -Type $exttype -TypeHandlerVersion $extver -AutoUpgradeMinorVersion $true `
66+
| Add-AzVmssDataDisk -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeGB 20 -Lun 1 -CreateOption Empty -DiskIOPSReadWrite 100 -DiskMBpsReadWrite 1000;
67+
6668

6769
# IP config and Network profile
6870
Assert-AreEqual $ipName $vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations[0].IpConfigurations[0].Name;
@@ -102,6 +104,14 @@ function Test-VirtualMachineScaleSetProfile
102104
Assert-AreEqual $imgRef.PublisherName $vmss.VirtualMachineProfile.StorageProfile.ImageReference.Publisher;
103105
Assert-Null $vmss.VirtualMachineProfile.StorageProfile.OsDisk.DiffDiskSettings;
104106

107+
Assert-AreEqual 'testDataDisk1' $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].Name;
108+
Assert-AreEqual 'ReadOnly' $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].Caching;
109+
Assert-AreEqual 20 $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].DiskSizeGB;
110+
Assert-AreEqual 1 $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].Lun;
111+
Assert-AreEqual 'Empty' $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].CreateOption;
112+
Assert-AreEqual 100 $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].DiskIOPSReadWrite;
113+
Assert-AreEqual 1000 $vmss.VirtualMachineProfile.StorageProfile.DataDisks[0].DiskMBpsReadWrite;
114+
105115
# Extension profile
106116
Assert-AreEqual $extname $vmss.VirtualMachineProfile.ExtensionProfile.Extensions[0].Name;
107117
Assert-AreEqual $publisher $vmss.VirtualMachineProfile.ExtensionProfile.Extensions[0].Publisher;

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,12 @@ public void TestVirtualMachineScaleSetScaleInPolicy()
156156
{
157157
TestRunner.RunTestScript("Test-VirtualMachineScaleSetScaleInPolicy");
158158
}
159+
160+
[Fact]
161+
[Trait(Category.AcceptanceType, Category.CheckIn)]
162+
public void TestVirtualMachineScaleSetAutoRepair()
163+
{
164+
TestRunner.RunTestScript("Test-VirtualMachineScaleSetAutoRepair");
165+
}
159166
}
160167
}

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,3 +2242,104 @@ function Test-VirtualMachineScaleSetScaleInPolicy
22422242
Clean-ResourceGroup $rgname
22432243
}
22442244
}
2245+
2246+
<#
2247+
.SYNOPSIS
2248+
Test Virtual Machine Scale Set Automatic Repairs Policy
2249+
#>
2250+
function Test-VirtualMachineScaleSetAutoRepair
2251+
{
2252+
# Setup
2253+
$rgname = Get-ComputeTestResourceName
2254+
2255+
try
2256+
{
2257+
# Common
2258+
[string]$loc = Get-ComputeVMLocation;
2259+
$loc = $loc.Replace(' ', '');
2260+
2261+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
2262+
2263+
# SRP
2264+
$stoname = 'sto' + $rgname;
2265+
$stotype = 'Standard_GRS';
2266+
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
2267+
$stoaccount = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname;
2268+
2269+
# NRP
2270+
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
2271+
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
2272+
$vnet = Get-AzVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
2273+
$subnetId = $vnet.Subnets[0].Id;
2274+
$pubip = New-AzPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
2275+
$pubip = Get-AzPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
2276+
2277+
# Create LoadBalancer
2278+
$frontendName = Get-ResourceName
2279+
$backendAddressPoolName = Get-ResourceName
2280+
$probeName = Get-ResourceName
2281+
$inboundNatPoolName = Get-ResourceName
2282+
$lbruleName = Get-ResourceName
2283+
$lbName = Get-ResourceName
2284+
2285+
$frontend = New-AzLoadBalancerFrontendIpConfig -Name $frontendName -PublicIpAddress $pubip
2286+
$backendAddressPool = New-AzLoadBalancerBackendAddressPoolConfig -Name $backendAddressPoolName
2287+
$probe = New-AzLoadBalancerProbeConfig -Name $probeName -RequestPath healthcheck.aspx -Protocol http -Port 80 -IntervalInSeconds 15 -ProbeCount 2
2288+
$inboundNatPool = New-AzLoadBalancerInboundNatPoolConfig -Name $inboundNatPoolName -FrontendIPConfigurationId `
2289+
$frontend.Id -Protocol Tcp -FrontendPortRangeStart 3360 -FrontendPortRangeEnd 3368 -BackendPort 3370;
2290+
$lbrule = New-AzLoadBalancerRuleConfig -Name $lbruleName `
2291+
-FrontendIPConfiguration $frontend -BackendAddressPool $backendAddressPool `
2292+
-Probe $probe -Protocol Tcp -FrontendPort 80 -BackendPort 80 `
2293+
-IdleTimeoutInMinutes 15 -EnableFloatingIP -LoadDistribution SourceIP;
2294+
$actualLb = New-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname -Location $loc `
2295+
-FrontendIpConfiguration $frontend -BackendAddressPool $backendAddressPool `
2296+
-Probe $probe -LoadBalancingRule $lbrule -InboundNatPool $inboundNatPool;
2297+
$expectedLb = Get-AzLoadBalancer -Name $lbName -ResourceGroupName $rgname
2298+
2299+
# New VMSS Parameters
2300+
$vmssName = 'vmss' + $rgname;
2301+
$adminUsername = 'Foo12';
2302+
$adminPassword = $PLACEHOLDER;
2303+
2304+
$imgRef = Get-DefaultCRPImage -loc $loc;
2305+
$vhdContainer = "https://" + $stoname + ".blob.core.windows.net/" + $vmssName;
2306+
2307+
$ipCfg = New-AzVmssIPConfig -Name 'test' `
2308+
-LoadBalancerInboundNatPoolsId $expectedLb.InboundNatPools[0].Id `
2309+
-LoadBalancerBackendAddressPoolsId $expectedLb.BackendAddressPools[0].Id `
2310+
-SubnetId $subnetId;
2311+
2312+
$vmss = New-AzVmssConfig -Location $loc -SkuCapacity 2 -SkuName 'Standard_A0' -UpgradePolicyMode 'Manual' -HealthProbeId $expectedLb.Probes[0].Id `
2313+
-EnableAutomaticRepair -AutomaticRepairGracePeriod "PT10S" -AutomaticRepairMaxInstanceRepairsPercent 100 `
2314+
| Add-AzVmssNetworkInterfaceConfiguration -Name 'test' -Primary $true -IPConfiguration $ipCfg `
2315+
| Set-AzVmssOSProfile -ComputerNamePrefix 'test' -AdminUsername $adminUsername -AdminPassword $adminPassword `
2316+
| Set-AzVmssStorageProfile -Name 'test' -OsDiskCreateOption 'FromImage' -OsDiskCaching 'None' `
2317+
-ImageReferenceOffer $imgRef.Offer -ImageReferenceSku $imgRef.Skus -ImageReferenceVersion 'latest' `
2318+
-ImageReferencePublisher $imgRef.PublisherName -VhdContainer $vhdContainer;
2319+
2320+
Assert-True { $vmss.AutomaticRepairsPolicy.Enabled };
2321+
Assert-AreEqual "PT10S" $vmss.AutomaticRepairsPolicy.GracePeriod;
2322+
Assert-AreEqual 100 $vmss.AutomaticRepairsPolicy.MaxInstanceRepairsPercent;
2323+
New-AzVmss -ResourceGroupName $rgname -Name $vmssName -VirtualMachineScaleSet $vmss;
2324+
2325+
$vmssResult = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
2326+
2327+
Assert-True { $vmssResult.AutomaticRepairsPolicy.Enabled };
2328+
Assert-AreEqual "PT10S" $vmssResult.AutomaticRepairsPolicy.GracePeriod;
2329+
Assert-AreEqual 100 $vmssResult.AutomaticRepairsPolicy.MaxInstanceRepairsPercent;
2330+
2331+
Update-AzVmss -ResourceGroupName $rgname -Name $vmssName -EnableAutomaticRepair $false;
2332+
2333+
$vmssResult = Get-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName;
2334+
2335+
Assert-False { $vmssResult.AutomaticRepairsPolicy.Enabled };
2336+
Assert-AreEqual "PT10S" $vmssResult.AutomaticRepairsPolicy.GracePeriod;
2337+
Assert-AreEqual 100 $vmssResult.AutomaticRepairsPolicy.MaxInstanceRepairsPercent;
2338+
}
2339+
finally
2340+
{
2341+
# Cleanup
2342+
Clean-ResourceGroup $rgname
2343+
}
2344+
}
2345+

0 commit comments

Comments
 (0)