@@ -53,6 +53,18 @@ Update-AzureRmVmssInstance 1.2.4 AzureRM.Compute
53
53
Test Virtual Machine Scale Set
54
54
#>
55
55
function Test-VirtualMachineScaleSet
56
+ {
57
+ Test-VirtualMachineScaleSet - Common $false
58
+ }
59
+ <#
60
+ . SYNOPSIS
61
+ Test Virtual Machine Scale Set with Managed disks
62
+ #>
63
+ function Test-VirtualMachineScaleSet-ManagedDisks
64
+ {
65
+ Test-VirtualMachineScaleSet - Common $true
66
+ }
67
+ function Test-VirtualMachineScaleSet-Common ($IsManaged )
56
68
{
57
69
# Setup
58
70
$rgname = Get-ComputeTestResourceName
@@ -91,16 +103,25 @@ function Test-VirtualMachineScaleSet
91
103
$extver = ' 2.1' ;
92
104
93
105
$ipCfg = New-AzureRmVmssIPConfig - Name ' test' - SubnetId $subnetId ;
94
- $vmss = New-AzureRmVmssConfig - Location $loc - SkuCapacity 2 - SkuName ' Standard_A0' - UpgradePolicyMode ' automatic' - NetworkInterfaceConfiguration $netCfg `
106
+ $vmss = New-AzureRmVmssConfig - Location $loc - SkuCapacity 2 - SkuName ' Standard_A0' - UpgradePolicyMode ' automatic' - NetworkInterfaceConfiguration $netCfg - Overprovision $false `
95
107
| Add-AzureRmVmssNetworkInterfaceConfiguration - Name ' test' - Primary $true - IPConfiguration $ipCfg `
96
108
| Set-AzureRmVmssOSProfile - ComputerNamePrefix ' test' - AdminUsername $adminUsername - AdminPassword $adminPassword `
97
- | Set-AzureRmVmssStorageProfile - Name ' test' - OsDiskCreateOption ' FromImage' - OsDiskCaching ' None' `
98
- - ImageReferenceOffer $imgRef.Offer - ImageReferenceSku $imgRef.Skus - ImageReferenceVersion $imgRef.Version `
99
- - ImageReferencePublisher $imgRef.PublisherName - VhdContainer $vhdContainer `
100
109
| Add-AzureRmVmssExtension - Name $extname - Publisher $publisher - Type $exttype - TypeHandlerVersion $extver - AutoUpgradeMinorVersion $true `
101
110
| Remove-AzureRmVmssExtension - Name $extname `
102
111
| Add-AzureRmVmssNetworkInterfaceConfiguration - Name ' test2' - IPConfiguration $ipCfg `
103
112
| Remove-AzureRmVmssNetworkInterfaceConfiguration - Name ' test2'
113
+ if ($IsManaged -eq $true )
114
+ {
115
+ $vmss = $vmss | Set-AzureRmVmssStorageProfile - OsDiskCreateOption ' FromImage' - OsDiskCaching ' None' `
116
+ - ImageReferenceOffer $imgRef.Offer - ImageReferenceSku $imgRef.Skus - ImageReferenceVersion $imgRef.Version `
117
+ - ImageReferencePublisher $imgRef.PublisherName
118
+ }
119
+ else
120
+ {
121
+ $vmss = $vmss | Set-AzureRmVmssStorageProfile - Name ' test' - OsDiskCreateOption ' FromImage' - OsDiskCaching ' None' `
122
+ - ImageReferenceOffer $imgRef.Offer - ImageReferenceSku $imgRef.Skus - ImageReferenceVersion $imgRef.Version `
123
+ - ImageReferencePublisher $imgRef.PublisherName - VhdContainer $vhdContainer `
124
+ }
104
125
105
126
# Validate Remove Network profile
106
127
Assert-AreEqual ' test' $vmss.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations [0 ].Name;
@@ -127,10 +148,14 @@ function Test-VirtualMachineScaleSet
127
148
Assert-Null $vmss.VirtualMachineProfile.OsProfile.AdminPassword ;
128
149
129
150
# Validate Storage Profile
130
- Assert-AreEqual ' test ' $vmss .VirtualMachineProfile.StorageProfile.OsDisk.Name ;
151
+
131
152
Assert-AreEqual ' FromImage' $vmss.VirtualMachineProfile.StorageProfile.OsDisk.CreateOption ;
132
153
Assert-AreEqual ' None' $vmss.VirtualMachineProfile.StorageProfile.OsDisk.Caching ;
133
- Assert-AreEqual $vhdContainer $vmss.VirtualMachineProfile.StorageProfile.OsDisk.VhdContainers [0 ];
154
+ if ($IsManaged -eq $false )
155
+ {
156
+ Assert-AreEqual ' test' $vmss.VirtualMachineProfile.StorageProfile.OsDisk.Name ;
157
+ Assert-AreEqual $vhdContainer $vmss.VirtualMachineProfile.StorageProfile.OsDisk.VhdContainers [0 ];
158
+ }
134
159
Assert-AreEqual $imgRef.Offer $vmss.VirtualMachineProfile.StorageProfile.ImageReference.Offer ;
135
160
Assert-AreEqual $imgRef.Skus $vmss.VirtualMachineProfile.StorageProfile.ImageReference.Sku ;
136
161
Assert-AreEqual $imgRef.Version $vmss.VirtualMachineProfile.StorageProfile.ImageReference.Version ;
@@ -201,6 +226,10 @@ function Test-VirtualMachineScaleSet
201
226
$st = $vmssResult | Start-AzureRmVmss ;
202
227
$st = $vmssResult | Restart-AzureRmVmss ;
203
228
229
+ if ($IsManaged -eq $true )
230
+ {
231
+ $st = $vmssResult | Set-AzureRmVmss - ReimageAll;
232
+ }
204
233
$instanceListParam = @ ();
205
234
for ($i = 0 ; $i -lt 2 ; $i ++ )
206
235
{
@@ -211,6 +240,13 @@ function Test-VirtualMachineScaleSet
211
240
$st = $vmssResult | Stop-AzureRmVmss - InstanceId $instanceListParam - Force;
212
241
$st = $vmssResult | Start-AzureRmVmss - InstanceId $instanceListParam ;
213
242
$st = $vmssResult | Restart-AzureRmVmss - InstanceId $instanceListParam ;
243
+ if ($IsManaged -eq $true )
244
+ {
245
+ for ($j = 0 ; $j -lt 2 ; $j ++ )
246
+ {
247
+ $st = Set-AzureRmVmssVM - ReimageAll - ResourceGroupName $rgname - VMScaleSetName $vmssName - InstanceId $j
248
+ }
249
+ }
214
250
215
251
# Remove
216
252
$st = Remove-AzureRmVmss - ResourceGroupName $rgname - VMScaleSetName $vmssName - InstanceId 1 - Force;
0 commit comments