Skip to content

Commit e5aa23a

Browse files
Merge pull request #431 from srdan-bozovic-msft/master
sql-managed-instance: prepare - a few fixes
2 parents 0000604 + 85cb49a commit e5aa23a

2 files changed

Lines changed: 9 additions & 14 deletions

File tree

samples/manage/azure-sql-db-managed-instance/prepare-subnet/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ $parameters = @{
5555
subnetName = '<subnetName>'
5656
}
5757
58-
Invoke-Command -ScriptBlock ([Scriptblock]::Create((New-Object System.Net.WebClient).DownloadString($scriptUrlBase+'/prepareSubnet.ps1?t='+ [DateTime]::Now.Ticks))) -ArgumentList $parameters
58+
Invoke-Command -ScriptBlock ([Scriptblock]::Create((iwr ($scriptUrlBase+'/prepareSubnet.ps1?t='+ [DateTime]::Now.Ticks)).Content)) -ArgumentList $parameters
5959
6060
```
6161

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

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,11 @@ function Ensure-Login ()
1212
If($context.Subscription -eq $null)
1313
{
1414
Write-Host "Loging in ..."
15-
Try
15+
If((Login-AzureRmAccount -ErrorAction SilentlyContinue -ErrorVariable Errors) -eq $null)
1616
{
17-
Login-AzureRmAccount -ErrorAction Stop | Out-null
17+
Write-Host ("Login failed: {0}" -f $Errors[0].Exception.Message) -ForegroundColor Red
18+
Break
1819
}
19-
Catch
20-
{
21-
Write-Host "Login failed: $_" -ForegroundColor Red
22-
Exit
23-
}
24-
2520
}
2621
Write-Host "User logedin." -ForegroundColor Green
2722
}
@@ -41,7 +36,7 @@ function Select-SubscriptionId {
4136
Catch
4237
{
4338
Write-Host "Subscription selection failed: $_" -ForegroundColor Red
44-
Exit
39+
Break
4540
}
4641
}
4742
Write-Host "Subscription selected." -ForegroundColor Green
@@ -62,7 +57,7 @@ function Load-VirtualNetwork {
6257
else
6358
{
6459
Write-Host "Virtual network not found." -ForegroundColor Red
65-
Exit
60+
Break
6661
}
6762
}
6863

@@ -83,7 +78,7 @@ function Load-VirtualNetworkSubnet {
8378
else
8479
{
8580
Write-Host "Subnet not found." -ForegroundColor Red
86-
Exit
81+
Break
8782
}
8883
}
8984

@@ -99,7 +94,7 @@ function Verify-Subnet {
9994
Else
10095
{
10196
Write-Host "Failed Validation - Minimum supported subnet size is /28." -ForegroundColor Red
102-
Exit
97+
Break
10398
}
10499
If(
105100
($subnet.IpConfigurations.Count -eq 0) -and
@@ -114,7 +109,7 @@ function Verify-Subnet {
114109
Else
115110
{
116111
Write-Host "Failed Validation - Subnet is already in use." -ForegroundColor Red
117-
Exit
112+
Break
118113
}
119114
}
120115

0 commit comments

Comments
 (0)