-
Notifications
You must be signed in to change notification settings - Fork 0
/
AzureRM - Azure SQL DB Server Connection Policy.ps1
57 lines (40 loc) · 1.55 KB
/
AzureRM - Azure SQL DB Server Connection Policy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Sign-in to Azure via Azure Resource Manager
Login-AzureRmAccount
# Select Azure Subscription
$subscriptionId =
( Get-AzureRmSubscription |
Out-GridView `
-Title "Select an Azure Subscription ..." `
-PassThru
).SubscriptionId
Select-AzureRmSubscription `
-SubscriptionId $subscriptionId
# Select Azure Resource Group
$rgName =
( Get-AzureRmResourceGroup |
Out-GridView `
-Title "Select an Azure Resource Group ..." `
-PassThru
).ResourceGroupName
# Select Azure SQL Database Server
$sqlServerName =
( Get-AzureRmSqlServer `
-ResourceGroupName $rgName |
Out-GridView `
-Title "Select an Azure SQL Server ..." `
-PassThru
).ServerName
$sqlServer = Get-AzureRmSqlServer `
-ResourceGroupName $rgName `
-ServerName $sqlServerName
# Set Azure SQL Database Server Default Connection Policy to Proxy
$sqlServerResourceId = "/subscriptions/$subscriptionId/resourceGroups/$rgName/providers/Microsoft.Sql/servers/$sqlServerName"
$location = $sqlServer.Location
$sqlConnectionPolicyId = "$sqlServerResourceId/connectionPolicies/Default"
New-AzureRmResource `
-ResourceId $sqlConnectionPolicyId `
-Location $location `
-Properties @{"connectionType"="Proxy"}
# Confirm configuration of Azure SQL Database Server Default Connection Policy
Get-AzureRmResource `
-ResourceId $sqlConnectionPolicyId