|
1 |
| -<# USAGE: ./CreateSQLVM.ps1 -Location "East US 2" -Size "Standard_D2as_v4" -ResourceGroupName "myTestResourceGroup" -VMAdminName "azureAdminName" -VMAdminPwd "aoeihag;ladjfalkj23" -SQLVersionEdition "2017" -SQLPort "41433" -SQLUserName "tSQLt_sa" -SQLPwd "aoeihag;ladjfalkj46" -BuildId "001" #> |
| 1 | +<# USAGE: |
| 2 | +
|
| 3 | +az login |
| 4 | +az account set --name "tSQLt CI Subscription" |
| 5 | +
|
| 6 | +./CreateSQLVM_azcli.ps1 -Location "East US 2" -Size "Standard_D2as_v4" -ResourceGroupName "myTestResourceGroup" -VMAdminName "azureadminname" -VMAdminPwd "aoeihag;ladjfalkj23" -SQLVersionEdition "2017" -SQLPort "41433" -SQLUserName "tSQLt_sa" -SQLPwd "aoeihag;ladjfalkj46" -BuildId "001" -VmPriority "Spot" |
| 7 | +#> |
2 | 8 | Param(
|
3 | 9 | [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $Location,
|
4 | 10 | [Parameter(Mandatory=$true)][ValidateNotNullOrEmpty()][string] $Size,
|
@@ -98,22 +104,30 @@ $FQDN = (az network public-ip show --resource-group $ResourceGroupName --name $P
|
98 | 104 | Log-Output "FQDN: ", $FQDN;
|
99 | 105 | Log-Output "DONE: Creating PIP $PipName";
|
100 | 106 |
|
101 |
| -Log-Output "START: Creating NSG and Rules $NsgName"; |
| 107 | +Log-Output "START: Creating NSG and Rules $NsgName --> nsg create"; |
102 | 108 | $output = az network nsg create --name $NsgName --resource-group $ResourceGroupName --location $Location | ConvertFrom-Json;
|
103 | 109 | if (!$output) {
|
104 | 110 | Write-Error "Error creating NIC";
|
105 | 111 | return
|
106 | 112 | }
|
| 113 | +Log-Output "START: Creating NSG and Rules $NsgName --> nsg rule create --name `"RDPRule`""; |
| 114 | +$DestPort = 3389; |
| 115 | +Log-Output "<-><-><-><-><-><-><-><-><-><-><-><-><-><->"; |
| 116 | +Log-Output "ResourceGroupName: ", $ResourceGroupName; |
| 117 | +Log-Output "NsgName: ", $NsgName; |
| 118 | +Log-Output "DestPort: ", $DestPort; |
| 119 | +Log-Output "<-><-><-><-><-><-><-><-><-><-><-><-><-><->"; |
107 | 120 | $output = az network nsg rule create --name "RDPRule" --nsg-name $NsgName --priority 1000 --resource-group $ResourceGroupName --access Allow `
|
108 |
| - --destination-address-prefixes * --destination-port-ranges 3389 --direction Inbound --protocol Tcp --source-address-prefixes * ` |
109 |
| - --source-port-ranges * | ConvertFrom-Json; |
| 121 | + --destination-address-prefixes '*' --destination-port-ranges $DestPort --direction Inbound --protocol Tcp --source-address-prefixes '*' ` |
| 122 | + --source-port-ranges '*' | ConvertFrom-Json; |
110 | 123 | if (!$output) {
|
111 | 124 | Write-Error "Error creating NIC RDPRule";
|
112 | 125 | return
|
113 | 126 | }
|
| 127 | +Log-Output "START: Creating NSG and Rules $NsgName --> nsg rule create --name `"MSSQLRule`""; |
114 | 128 | $output = az network nsg rule create --name "MSSQLRule" --nsg-name $NsgName --priority 1001 --resource-group $ResourceGroupName --access Allow `
|
115 |
| - --destination-address-prefixes * --destination-port-ranges $SQLPort --direction Inbound --protocol Tcp --source-address-prefixes * ` |
116 |
| - --source-port-ranges * | ConvertFrom-Json; |
| 129 | + --destination-address-prefixes '*' --destination-port-ranges $SQLPort --direction Inbound --protocol Tcp --source-address-prefixes '*' ` |
| 130 | + --source-port-ranges '*' | ConvertFrom-Json; |
117 | 131 | if (!$output) {
|
118 | 132 | Write-Error "Error creating NIC MSSQLRule";
|
119 | 133 | return
|
@@ -163,7 +177,7 @@ $SQLVM|Out-String|Log-Output;
|
163 | 177 | Log-Output 'DONE: Applying SqlVM Config'
|
164 | 178 |
|
165 | 179 | Log-Output 'START: Prep SQL Server for tSQLt Build'
|
166 |
| -$DS = Invoke-Sqlcmd -InputFile "$dir/GetSQLServerVersion.sql" -ServerInstance "$FQDN,$SQLPort" -Username "$SQLUserName" -Password "$SQLPwd" -As DataSet |
| 180 | +$DS = Invoke-Sqlcmd -InputFile "$dir/GetSQLServerVersion.sql" -ServerInstance "$FQDN,$SQLPort" -Username "$SQLUserName" -Password "$SQLPwd" -As DataSet -TrustServerCertificate |
167 | 181 | $DS.Tables[0].Rows | %{ Log-Output "{ $($_['LoginName']), $($_['TimeStamp']), $($_['VersionDetail']), $($_['ProductVersion']), $($_['ProductLevel']), $($_['SqlVersion']), $($_['ServerCollation']) }" }
|
168 | 182 |
|
169 | 183 | $ActualSQLVersion = $DS.Tables[0].Rows[0]['SqlVersion'];
|
|
0 commit comments