12
12
# limitations under the License.
13
13
# ----------------------------------------------------------------------------------
14
14
15
+ # Location to use for provisioning test managed instances
16
+ $instanceLocation = " eastus"
17
+
15
18
<#
16
19
. SYNOPSIS
17
20
Tests creating a managed instance
@@ -37,9 +40,9 @@ function Test-CreateManagedInstance
37
40
$proxyOverride = " Proxy"
38
41
try
39
42
{
40
- # Setup VNET
43
+ # Setup VNET
41
44
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location " newprovisioningtest"
42
- $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName }).Id
45
+ $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName })[ 0 ] .Id
43
46
44
47
# With SKU name specified
45
48
$job = New-AzSqlInstance - ResourceGroupName $rg.ResourceGroupName - Name $managedInstanceName `
@@ -109,9 +112,9 @@ function Test-SetManagedInstance
109
112
$vnetName = " vnet-newprovisioningtest3"
110
113
$subnetName = " ManagedInstance"
111
114
112
- # Setup VNET
115
+ # Setup VNET
113
116
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location " newprovisioningtest"
114
- $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName }).Id
117
+ $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName })[ 0 ] .Id
115
118
116
119
$managedInstance = Create- ManagedInstanceForTest $rg $subnetId
117
120
@@ -125,14 +128,14 @@ function Test-SetManagedInstance
125
128
126
129
$managedInstance1 = Set-AzSqlInstance - ResourceGroupName $rg.ResourceGroupName - Name $managedInstance.ManagedInstanceName `
127
130
- AdministratorPassword $credentials.Password - LicenseType $licenseType - StorageSizeInGB $storageSizeInGB - Vcore $vCore - Force
128
-
131
+
129
132
Assert-AreEqual $managedInstance1.ManagedInstanceName $managedInstance.ManagedInstanceName
130
133
Assert-AreEqual $managedInstance1.AdministratorLogin $managedInstance.AdministratorLogin
131
134
Assert-AreEqual $managedInstance1.LicenseType $licenseType
132
135
Assert-AreEqual $managedInstance1.VCores $vCore
133
136
Assert-AreEqual $managedInstance1.StorageSizeInGB $storageSizeInGB
134
137
Assert-StartsWith ($managedInstance1.ManagedInstanceName + " ." ) $managedInstance1.FullyQualifiedDomainName
135
-
138
+
136
139
# Test using piping
137
140
$credentials = Get-ServerCredential
138
141
@@ -158,7 +161,7 @@ function Test-SetManagedInstance
158
161
159
162
$managedInstance3 = Set-AzSqlInstance - InputObject $managedInstance `
160
163
- AdministratorPassword $credentials.Password - LicenseType $licenseType - StorageSizeInGB $storageSizeInGB - Vcore $vCore - Force
161
-
164
+
162
165
Assert-AreEqual $managedInstance3.ManagedInstanceName $managedInstance.ManagedInstanceName
163
166
Assert-AreEqual $managedInstance3.AdministratorLogin $managedInstance.AdministratorLogin
164
167
Assert-AreEqual $managedInstance3.LicenseType $licenseType
@@ -177,7 +180,7 @@ function Test-SetManagedInstance
177
180
$managedInstance4 = Set-AzSqlInstance - ResourceId $managedInstance.Id `
178
181
- AdministratorPassword $credentials.Password - LicenseType $licenseType - StorageSizeInGB $storageSizeInGB - Vcore $vCore `
179
182
- PublicDataEndpointEnabled $publicDataEndpointEnabled - ProxyOverride $proxyOverride - Force
180
-
183
+
181
184
Assert-AreEqual $managedInstance4.ManagedInstanceName $managedInstance.ManagedInstanceName
182
185
Assert-AreEqual $managedInstance4.AdministratorLogin $managedInstance.AdministratorLogin
183
186
Assert-AreEqual $managedInstance4.LicenseType $licenseType
@@ -202,14 +205,14 @@ function Test-SetManagedInstance
202
205
function Test-GetManagedInstance
203
206
{
204
207
# Setup
205
- $rg = Create- ResourceGroupForTest
206
- $rg1 = Create- ResourceGroupForTest
208
+ $rg = Create- ResourceGroupForTest $instanceLocation
209
+ $rg1 = Create- ResourceGroupForTest $instanceLocation
207
210
$vnetName = " cl_initial"
208
211
$subnetName = " CooL"
209
212
210
- # Setup VNET
211
- $virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
212
- $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName }).Id
213
+ # Setup VNET
214
+ $virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location " powershell_mi "
215
+ $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName })[ 0 ] .Id
213
216
214
217
$managedInstance1 = Create- ManagedInstanceForTest $rg $subnetId
215
218
$managedInstance2 = Create- ManagedInstanceForTest $rg1 $subnetId
@@ -225,7 +228,7 @@ function Test-GetManagedInstance
225
228
Assert-AreEqual $managedInstance1.LicenseType $resp1.LicenseType
226
229
Assert-AreEqual $managedInstance1.VCores $resp1.VCores
227
230
Assert-AreEqual $managedInstance1.StorageSizeInGB $resp1.StorageSizeInGB
228
-
231
+
229
232
$all = Get-AzSqlInstance - ResourceGroupName $rg.ResourceGroupName - Name *
230
233
Assert-AreEqual 1 $all.Count
231
234
@@ -252,20 +255,20 @@ function Test-GetManagedInstance
252
255
function Test-RemoveManagedInstance
253
256
{
254
257
# Setup
255
- $rg = Create- ResourceGroupForTest
258
+ $rg = Create- ResourceGroupForTest $instanceLocation
256
259
$vnetName = " cl_initial"
257
260
$subnetName = " CooL"
258
261
259
- # Setup VNET
260
- $virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
261
- $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName }).Id
262
+ # Setup VNET
263
+ $virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location " powershell_mi "
264
+ $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName })[ 0 ] .Id
262
265
263
266
try
264
267
{
265
268
# Test using parameters
266
269
$managedInstance1 = Create- ManagedInstanceForTest $rg $subnetId
267
270
Remove-AzSqlInstance - ResourceGroupName $rg.ResourceGroupName - Name $managedInstance1.ManagedInstanceName - Force
268
-
271
+
269
272
# Test using InputObject
270
273
$managedInstance2 = Create- ManagedInstanceForTest $rg $subnetId
271
274
Remove-AzSqlInstance - InputObject $managedInstance2 - Force
@@ -298,9 +301,9 @@ function Test-CreateManagedInstanceWithIdentity
298
301
$vnetName = " cl_initial"
299
302
$subnetName = " CooL"
300
303
301
- # Setup VNET
304
+ # Setup VNET
302
305
$virtualNetwork1 = CreateAndGetVirtualNetworkForManagedInstance $vnetName $subnetName $rg.Location
303
- $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName }).Id
306
+ $subnetId = $virtualNetwork1.Subnets.where ({ $_.Name -eq $subnetName })[ 0 ] .Id
304
307
305
308
$managedInstanceName = Get-ManagedInstanceName
306
309
$version = " 12.0"
0 commit comments