Skip to content

Commit 6e4ea5f

Browse files
committed
Check NAT gateway associated with subnet
1 parent 7385751 commit 6e4ea5f

1 file changed

Lines changed: 20 additions & 18 deletions

File tree

samples/manage/azure-sql-db-managed-instance/prepare-subnet/prepareSubnet.ps1

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -183,31 +183,33 @@ function VerifySubnet {
183183
param (
184184
$subnet
185185
)
186-
Write-Host("Verifying subnet '{0}'." -f $subnet.Name)
187-
If($subnet.AddressPrefix.Split('/')[1] -le 28)
188-
{
189-
Write-Host "Passed Validation - Subnet is of enough size." -ForegroundColor Green
190-
}
191-
Else
192-
{
193-
Write-Host "Failed Validation - Minimum supported subnet size is /28." -ForegroundColor Red
194-
Break
195-
}
196-
If(
186+
Write-Host("Verifying subnet '{0}'." -f $subnet.Name)
187+
If ($subnet.AddressPrefix.Split('/')[1] -le 28) {
188+
Write-Host "Passed Validation - Subnet is of enough size." -ForegroundColor Green
189+
}
190+
Else {
191+
Write-Host "Failed Validation - Minimum supported subnet size is /28." -ForegroundColor Red
192+
Break
193+
}
194+
If (
197195
($subnet.IpConfigurations.Count -eq 0) -and
198196
(
199197
($subnet.ResourceNavigationLinks.Count -eq 0) -or
200198
($subnet.ResourceNavigationLinks[0].LinkedResourceType -eq 'Microsoft.Sql/virtualClusters')
201199
)
202-
)
203-
{
204-
Write-Host "Passed Validation - There are no conflicting resources inside the subnet." -ForegroundColor Green
205-
}
206-
Else
207-
{
208-
Write-Host "Failed Validation - Subnet is already in use." -ForegroundColor Red
200+
) {
201+
If ($subnet.NatGateway.Id) {
202+
Write-Host "Failed Validation - There is a NAT gateway associated with this subnet." -ForegroundColor Red
209203
Break
210204
}
205+
Else {
206+
Write-Host "Passed Validation - There are no conflicting resources inside the subnet." -ForegroundColor Green
207+
}
208+
}
209+
Else {
210+
Write-Host "Failed Validation - Subnet is already in use." -ForegroundColor Red
211+
Break
212+
}
211213
}
212214

213215

0 commit comments

Comments
 (0)