-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate_Database.ps1
69 lines (58 loc) · 1.61 KB
/
Create_Database.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
58
59
60
61
62
63
64
65
66
67
68
69
<#
.SYNOPSIS
. Creates the SQL server, database, user account, and firewall exception where you need to managed the DB
.DESCRIPTION
Long description
.EXAMPLE
PS C:\> <example usage>
Explanation of what the example does
.INPUTS
Inputs (if any)
.OUTPUTS
Output (if any)
.NOTES
General notes
#>
$SubID = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx"
$Location = "northcentralus"
$ResourceGroup = "xxxrg"
$SQLAdminCred = Get-Credential -Message "Enter the SQL Admin credentials you want to set"
$SQLSRVName = "xx"
$SQLDBName = "xx"
$SQLDBTier = "Basic"
$sqlClientPIP = "x.x.x.x"
# End of static variables
$SQLAdminUN = $SQLAdminCred.UserName
$SQLAdminPW = $SQLAdminCred.GetNetworkCredential().Password
az login
write-host "Setting the default subscription"
az account set --subscription $SubID
write-host "Creating the resource Group"
az group create `
--location $Location `
--name $ResourceGroup `
--location $Location `
--verbose
write-host "Creating the SQL Server"
az sql server create `
--admin-user $SQLAdminUN `
--admin-password $SQLAdminPW `
--name $SQLSRVName `
--resource-group $ResourceGroup `
--location $Location `
--verbose
write-host "Creating the Database"
az sql db create `
--name $SQLDBName `
--resource-group $ResourceGroup `
--server $SQLSRVName `
--tier $SQLDBTier `
--verbose
write-host "Creating the firewall Rule"
az sql server firewall-rule create `
--name grafanaapp `
--server $SQLSRVName `
--resource-group $ResourceGroup `
--start-ip-address $sqlClientPIP `
--end-ip-address $sqlClientPIP `
--verbose