Skip to content

Commit

Permalink
Making exceptions for 2008R2
Browse files Browse the repository at this point in the history
  • Loading branch information
lizbaron committed Feb 16, 2022
1 parent 05b7364 commit 62e72ed
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 7 deletions.
16 changes: 9 additions & 7 deletions CI/Azure-DevOps/CreateSQLVM_azcli.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ Log-Output "<-><-><-><-><-><-><-><-><-><-><-><-><-><->";
URN for az cli --> $SQLVersionEditionInfo.publisher+":"+$SQLVersionEditionInfo.offer+":"+$SQLVersionEditionInfo.sku+":"+$SQLVersionEditionInfo.version
#>
$SQLVersionEditionHash = @{
"2008R2Std"=@{"sqlversion"="2008R2";"offer"="SQL2008R2SP3-WS2008R2SP1";"publisher"="microsoftsqlserver";"sku"="Standard";"osType"="Windows";"version"="latest"}; #MicrosoftSQLServer:SQL2008R2SP3-WS2008R2SP1:Standard:latest
"2012Ent"=@{"sqlversion"="2012";"offer"="SQL2012SP4-WS2012R2";"publisher"="microsoftsqlserver";"sku"="Enterprise";"osType"="Windows";"version"="latest"}; #MicrosoftSQLServer:SQL2012SP4-WS2012R2:Enterprise:latest
"2014"=@{"sqlversion"="2014";"offer"="sql2014sp3-ws2012r2";"publisher"="microsoftsqlserver";"sku"="sqldev";"osType"="Windows";"version"="latest"}; #MicrosoftSQLServer:sql2014sp3-ws2012r2:sqldev:latest
"2016"=@{"sqlversion"="2016";"offer"="SQL2016SP2-WS2016";"publisher"="microsoftsqlserver";"sku"="sqldev";"osType"="Windows";"version"="latest"}; #MicrosoftSQLServer:sql2016sp2-ws2019:sqldev:latest
"2017"=@{"sqlversion"="2017";"offer"="sql2017-ws2019";"publisher"="microsoftsqlserver";"sku"="sqldev";"osType"="Windows";"version"="latest"}; #MicrosoftSQLServer:sql2017-ws2019:sqldev:latest
"2019"=@{"sqlversion"="2019";"offer"="sql2019-ws2019";"publisher"="microsoftsqlserver";"sku"="sqldev";"osType"="Windows";"version"="latest"} #MicrosoftSQLServer:sql2019-ws2019:sqldev:latest
"2008R2Std"=@{"sqlversion"="2008R2";"offer"="SQL2008R2SP3-WS2008R2SP1";"publisher"="microsoftsqlserver";"sku"="Standard";"osType"="Windows";"version"="latest";"bicep"="CreateSqlVirtualMachineTemplate-2008R2.bicep"}; #MicrosoftSQLServer:SQL2008R2SP3-WS2008R2SP1:Standard:latest
"2012Ent"=@{"sqlversion"="2012";"offer"="SQL2012SP4-WS2012R2";"publisher"="microsoftsqlserver";"sku"="Enterprise";"osType"="Windows";"version"="latest";"bicep"="CreateSQLVirtualMachineTemplate.bicep"}; #MicrosoftSQLServer:SQL2012SP4-WS2012R2:Enterprise:latest
"2014"=@{"sqlversion"="2014";"offer"="sql2014sp3-ws2012r2";"publisher"="microsoftsqlserver";"sku"="sqldev";"osType"="Windows";"version"="latest";"bicep"="CreateSQLVirtualMachineTemplate.bicep"}; #MicrosoftSQLServer:sql2014sp3-ws2012r2:sqldev:latest
"2016"=@{"sqlversion"="2016";"offer"="SQL2016SP2-WS2016";"publisher"="microsoftsqlserver";"sku"="sqldev";"osType"="Windows";"version"="latest";"bicep"="CreateSQLVirtualMachineTemplate.bicep"}; #MicrosoftSQLServer:sql2016sp2-ws2019:sqldev:latest
"2017"=@{"sqlversion"="2017";"offer"="sql2017-ws2019";"publisher"="microsoftsqlserver";"sku"="sqldev";"osType"="Windows";"version"="latest";"bicep"="CreateSQLVirtualMachineTemplate.bicep"}; #MicrosoftSQLServer:sql2017-ws2019:sqldev:latest
"2019"=@{"sqlversion"="2019";"offer"="sql2019-ws2019";"publisher"="microsoftsqlserver";"sku"="sqldev";"osType"="Windows";"version"="latest";"bicep"="CreateSQLVirtualMachineTemplate.bicep"} #MicrosoftSQLServer:sql2019-ws2019:sqldev:latest
};

$SQLVersionEditionInfo = $SQLVersionEditionHash.$SQLVersionEdition;
$ImageUrn = $SQLVersionEditionInfo.publisher+":"+$SQLVersionEditionInfo.offer+":"+$SQLVersionEditionInfo.sku+":"+$SQLVersionEditionInfo.version;
$TemplateFile = $dir + "/" + $SQLVersionEditionInfo.bicep;
Log-Output "ImageUrn: ", $ImageUrn;
Log-Output "SQLVersionEditionInfo: ", $SQLVersionEditionInfo;
Log-Output "TemplateFile: ", $TemplateFile;

Log-Output "START: Creating Resource Group $ResourceGroupName";
$output = az group create --location "$Location" --name "$ResourceGroupName" | ConvertFrom-Json;
Expand Down Expand Up @@ -151,7 +153,7 @@ Log-Output "VmResourceId: ", $VmResourceId;
Log-Output "DONE: Creating VM $VMName";

Log-Output 'START: Applying SqlVM Config'
$output = az deployment group create --resource-group $ResourceGroupName --template-file "$dir/CreateSQLVirtualMachineTemplate.bicep" `
$output = az deployment group create --resource-group $ResourceGroupName --template-file "$TemplateFile" `
--parameters sqlPortNumber=$SQLPort sqlAuthenticationLogin="$SQLUserName" sqlAuthenticationPassword="$SQLPwd" newVMName="$VMName" newVMRID="$VmResourceId" | ConvertFrom-Json;
if (!$output) {
Write-Error "Error creating SqlVM";
Expand Down
59 changes: 59 additions & 0 deletions CI/Azure-DevOps/CreateSqlVirtualMachineTemplate-2008R2.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
param sqlConnectivityType string = 'Public'
param sqlPortNumber int = 41433
param sqlStorageWorkloadType string = 'General'
param sqlStorageDisksConfigurationType string = 'NEW'
param sqlDataSettingsDefaultFilePath string = 'F:\\data'
param sqlDataSettingsLUNs array = [
0
]
param sqlLogSettingsDefaultFilePath string = 'F:\\log'
param sqlLogSettingsLUNs array = [
0
]
param sqlAutopatchingDayOfWeek string = 'Sunday'
param sqlAutopatchingStartHour int = 2
param sqlAutopatchingWindowDuration int = 60
param sqlAuthenticationLogin string = 'tSQLt'
param sqlAuthenticationPassword string = 'sdlfksdlkfjlsdkjf39939^'
param newVMName string = 'V1052sql2014sp3'
param newVMRID string = '/subscriptions/58c04a99-5b92-410c-9e41-10262f68ca80/resourceGroups/tSQLtCI_DevTestLab_20200318_1052-V1052sql2014sp3-155797/providers/Microsoft.Compute/virtualMachines/V1052sql2014sp3'

resource newVMName_resource 'Microsoft.SqlVirtualMachine/SqlVirtualMachines@2017-03-01-preview' = {
name: newVMName
location: resourceGroup().location
properties: {
virtualMachineResourceId: newVMRID
sqlManagement: 'Full'
sqlServerLicenseType: 'PAYG'
autoPatchingSettings: {
enable: true
dayOfWeek: sqlAutopatchingDayOfWeek
maintenanceWindowStartingHour: sqlAutopatchingStartHour
maintenanceWindowDuration: sqlAutopatchingWindowDuration
}
keyVaultCredentialSettings: {
enable: false
credentialName: ''
}
storageConfigurationSettings: {
diskConfigurationType: sqlStorageDisksConfigurationType
sqlDataSettings : {
luns: sqlDataSettingsLUNs
defaultFilePath: sqlDataSettingsDefaultFilePath
}
sqlLogSettings: {
luns: sqlLogSettingsLUNs
defaultFilePath: sqlLogSettingsDefaultFilePath
}
storageWorkloadType: sqlStorageWorkloadType
}
serverConfigurationsManagementSettings: {
sqlConnectivityUpdateSettings: {
connectivityType: sqlConnectivityType
port: sqlPortNumber
sqlAuthUpdateUserName: sqlAuthenticationLogin
sqlAuthUpdatePassword: sqlAuthenticationPassword
}
}
}
}

0 comments on commit 62e72ed

Please sign in to comment.