@@ -22,7 +22,7 @@ $ImageSku = '2025-datacenter-azure-edition'
22
22
23
23
$LogFile = ' 1es-hosted-pool.log'
24
24
$ProgressActivity = ' Preparing STL CI pool'
25
- $TotalProgress = 26
25
+ $TotalProgress = 38
26
26
$CurrentProgress = 1
27
27
28
28
<#
@@ -103,20 +103,54 @@ $AdminPWSecure = New-Password
103
103
$Credential = New-Object System.Management.Automation.PSCredential (' AdminUser' , $AdminPWSecure )
104
104
105
105
# ###################################################################################################
106
- Display- ProgressBar - Status ' Creating virtual network'
106
+ Display- ProgressBar - Status ' Creating public IP address'
107
+
108
+ $PublicIpAddressName = $ResourceGroupName + ' -PublicIpAddress'
109
+ $PublicIpAddress = New-AzPublicIpAddress `
110
+ - Name $PublicIpAddressName `
111
+ - ResourceGroupName $ResourceGroupName `
112
+ - Location $Location `
113
+ - Sku ' Standard' `
114
+ - AllocationMethod ' Static'
115
+
116
+ # ###################################################################################################
117
+ Display- ProgressBar - Status ' Creating NAT gateway'
118
+
119
+ $NatGatewayName = $ResourceGroupName + ' -NatGateway'
120
+ $NatGateway = New-AzNatGateway `
121
+ - Name $NatGatewayName `
122
+ - ResourceGroupName $ResourceGroupName `
123
+ - Location $Location `
124
+ - IdleTimeoutInMinutes 10 `
125
+ - Sku ' Standard' `
126
+ - PublicIpAddress $PublicIpAddress
127
+
128
+ # ###################################################################################################
129
+ Display- ProgressBar - Status ' Creating network security group'
107
130
108
131
$NetworkSecurityGroupName = $ResourceGroupName + ' -NetworkSecurity'
109
132
$NetworkSecurityGroup = New-AzNetworkSecurityGroup `
110
133
- Name $NetworkSecurityGroupName `
111
134
- ResourceGroupName $ResourceGroupName `
112
135
- Location $Location
113
136
137
+ # ###################################################################################################
138
+ Display- ProgressBar - Status ' Creating virtual network subnet config'
139
+
140
+ # TRANSITION, 2025-09-30: "On September 30, 2025, default outbound access for new deployments will be retired."
141
+ # https://learn.microsoft.com/en-us/azure/virtual-network/ip-services/default-outbound-access
142
+ # We're using `-DefaultOutboundAccess $false` to opt-in early.
114
143
$SubnetName = $ResourceGroupName + ' -Subnet'
115
144
$Subnet = New-AzVirtualNetworkSubnetConfig `
116
145
- Name $SubnetName `
117
146
- AddressPrefix ' 10.0.0.0/16' `
147
+ - DefaultOutboundAccess $false `
148
+ - NatGateway $NatGateway `
118
149
- NetworkSecurityGroup $NetworkSecurityGroup
119
150
151
+ # ###################################################################################################
152
+ Display- ProgressBar - Status ' Creating virtual network'
153
+
120
154
$VirtualNetworkName = $ResourceGroupName + ' -Network'
121
155
$VirtualNetwork = New-AzVirtualNetwork `
122
156
- Name $VirtualNetworkName `
@@ -136,7 +170,7 @@ $Nic = New-AzNetworkInterface `
136
170
- Subnet $VirtualNetwork.Subnets [0 ]
137
171
138
172
# ###################################################################################################
139
- Display- ProgressBar - Status ' Creating prototype VM'
173
+ Display- ProgressBar - Status ' Creating prototype VM config '
140
174
141
175
# Previously: -Priority 'Spot'
142
176
$VM = New-AzVMConfig `
@@ -145,33 +179,51 @@ $VM = New-AzVMConfig `
145
179
- DiskControllerType ' NVMe' `
146
180
- Priority ' Regular'
147
181
182
+ # ###################################################################################################
183
+ Display- ProgressBar - Status ' Setting prototype VM OS'
184
+
148
185
$VM = Set-AzVMOperatingSystem `
149
186
- VM $VM `
150
187
- Windows `
151
188
- ComputerName $ProtoVMName `
152
189
- Credential $Credential `
153
190
- ProvisionVMAgent
154
191
192
+ # ###################################################################################################
193
+ Display- ProgressBar - Status ' Adding prototype VM network interface'
194
+
155
195
$VM = Add-AzVMNetworkInterface `
156
196
- VM $VM `
157
197
- Id $Nic.Id
158
198
199
+ # ###################################################################################################
200
+ Display- ProgressBar - Status ' Setting prototype VM source image'
201
+
159
202
$VM = Set-AzVMSourceImage `
160
203
- VM $VM `
161
204
- PublisherName $ImagePublisher `
162
205
- Offer $ImageOffer `
163
206
- Skus $ImageSku `
164
207
- Version ' latest'
165
208
209
+ # ###################################################################################################
210
+ Display- ProgressBar - Status ' Setting prototype VM boot diagnostic'
211
+
166
212
$VM = Set-AzVMBootDiagnostic `
167
213
- VM $VM `
168
214
- Disable
169
215
216
+ # ###################################################################################################
217
+ Display- ProgressBar - Status ' Creating prototype VM'
218
+
170
219
New-AzVm `
171
220
- ResourceGroupName $ResourceGroupName `
172
221
- Location $Location `
173
222
- VM $VM >> $LogFile
174
223
224
+ # ###################################################################################################
225
+ Display- ProgressBar - Status ' Getting prototype VM OS disk name'
226
+
175
227
$VM = Get-AzVM `
176
228
- ResourceGroupName $ResourceGroupName `
177
229
- Name $ProtoVMName
@@ -350,25 +402,41 @@ Remove-AzDisk `
350
402
Display- ProgressBar - Status ' Deleting unused network interface'
351
403
352
404
Remove-AzNetworkInterface `
353
- - ResourceGroupName $ResourceGroupName `
354
- - Name $NicName `
355
- - Force >> $LogFile
405
+ - ResourceGroupName $ResourceGroupName `
406
+ - Name $NicName `
407
+ - Force >> $LogFile
356
408
357
409
# ###################################################################################################
358
410
Display- ProgressBar - Status ' Deleting unused virtual network'
359
411
360
412
Remove-AzVirtualNetwork `
361
- - ResourceGroupName $ResourceGroupName `
362
- - Name $VirtualNetworkName `
363
- - Force >> $LogFile
413
+ - ResourceGroupName $ResourceGroupName `
414
+ - Name $VirtualNetworkName `
415
+ - Force >> $LogFile
364
416
365
417
# ###################################################################################################
366
418
Display- ProgressBar - Status ' Deleting unused network security group'
367
419
368
420
Remove-AzNetworkSecurityGroup `
369
- - ResourceGroupName $ResourceGroupName `
370
- - Name $NetworkSecurityGroupName `
371
- - Force >> $LogFile
421
+ - ResourceGroupName $ResourceGroupName `
422
+ - Name $NetworkSecurityGroupName `
423
+ - Force >> $LogFile
424
+
425
+ # ###################################################################################################
426
+ Display- ProgressBar - Status ' Deleting unused NAT gateway'
427
+
428
+ Remove-AzNatGateway `
429
+ - ResourceGroupName $ResourceGroupName `
430
+ - Name $NatGatewayName `
431
+ - Force >> $LogFile
432
+
433
+ # ###################################################################################################
434
+ Display- ProgressBar - Status ' Deleting unused public IP address'
435
+
436
+ Remove-AzPublicIpAddress `
437
+ - ResourceGroupName $ResourceGroupName `
438
+ - Name $PublicIpAddressName `
439
+ - Force >> $LogFile
372
440
373
441
# ###################################################################################################
374
442
Write-Progress - Activity $ProgressActivity - Completed
0 commit comments