Closed terminal3 closed 6 years ago
This also seems to apply to other resources deployed by the MySQL task into the same resource group.
Thanks for catching this. Use the following code to replace that SQL Hosting VM Deployment - it should work although I haven't tested. It should now check to see if SkipMySQL was true, and if it was, it should create the RG and not try to use an existing non-existent vNet for deployment. Let me know!
Thanks!
#### DEPLOY SQL SERVER VM TO HOST USER DATABASES #############################################################################################################
##############################################################################################################################################################
$RowIndex = [array]::IndexOf($progress.Stage, "SQLServerDBVM")
$scriptStep = $($progress[$RowIndex].Stage).ToString().ToUpper()
if ($progress[$RowIndex].Status -eq "Complete") {
Write-CustomVerbose -Message "ASDK Configuration Stage: $($progress[$RowIndex].Stage) previously completed successfully"
}
elseif ((!$skipMSSQL) -and ($progress[$RowIndex].Status -ne "Complete")) {
# We first need to check if in a previous run, this section was skipped, but now, the user wants to add this, so we need to reset the progress.
if ($progress[$RowIndex].Status -eq "Skipped") {
Write-CustomVerbose -Message "Operator previously skipped this step, but now wants to perform this step. Updating ConfigASDKProgressLog.csv file to Incomplete."
# Update the ConfigASDKProgressLog.csv file with successful completion
$progress[$RowIndex].Status = "Incomplete"
$progress | Export-Csv $ConfigASDKProgressLogPath -NoTypeInformation -Force
$RowIndex = [array]::IndexOf($progress.Stage, "SQLServerDBVM")
}
if (($progress[$RowIndex].Status -eq "Incomplete") -or ($progress[$RowIndex].Status -eq "Failed")) {
try {
# Deploy a SQL Server 2017 on Ubuntu VM for hosting tenant db
if ($skipMySQL) {
#if MySQL RP was skipped, DB hosting resources should be created here
Write-CustomVerbose -Message "Creating a dedicated Resource Group for all database hosting assets"
New-AzureRmResourceGroup -Name "azurestack-dbhosting" -Location $azsLocation -Force
Write-CustomVerbose -Message "Creating a dedicated SQL Server 2017 on Ubuntu 16.04 LTS for database hosting"
New-AzureRmResourceGroupDeployment -Name "SQLHost" -ResourceGroupName "azurestack-dbhosting" -TemplateUri https://raw.githubusercontent.com/mattmcspirit/azurestack/master/deployment/packages/MSSQL/ASDK.MSSQL/DeploymentTemplates/mainTemplate.json `
-vmName "sqlhost" -adminUsername "sqladmin" -adminPassword $secureVMpwd -msSQLPassword $secureVMpwd `
-virtualNetworkName "dbhosting_vnet" -virtualNetworkSubnetName "dbhosting_subnet" -publicIPAddressDomainNameLabel "sqlhost" -vmSize Standard_A3 -mode Incremental -Verbose -ErrorAction Stop
}
else {
# Assume MySQL RP was deployed, and DB Hosting RG and networks were previously created
Write-CustomVerbose -Message "Creating a dedicated SQL Server 2017 on Ubuntu 16.04 LTS for database hosting"
New-AzureRmResourceGroupDeployment -Name "SQLHost" -ResourceGroupName "azurestack-dbhosting" -TemplateUri https://raw.githubusercontent.com/mattmcspirit/azurestack/master/deployment/packages/MSSQL/ASDK.MSSQL/DeploymentTemplates/mainTemplate.json `
-vmName "sqlhost" -adminUsername "sqladmin" -adminPassword $secureVMpwd -msSQLPassword $secureVMpwd `
-virtualNetworkNewOrExisting "existing" -virtualNetworkName "dbhosting_vnet" -virtualNetworkSubnetName "dbhosting_subnet" -publicIPAddressDomainNameLabel "sqlhost" -vmSize Standard_A3 -mode Incremental -Verbose -ErrorAction Stop
}
# Update the ConfigASDKProgressLog.csv file with successful completion
Write-CustomVerbose -Message "Updating ConfigASDKProgressLog.csv file with successful completion`r`n"
$progress[$RowIndex].Status = "Complete"
$progress | Export-Csv $ConfigASDKProgressLogPath -NoTypeInformation -Force
Write-Output $progress | Out-Host
}
catch {
Write-CustomVerbose -Message "ASDK Configuration Stage: $($progress[$RowIndex].Stage) Failed`r`n"
$progress[$RowIndex].Status = "Failed"
$progress | Export-Csv $ConfigASDKProgressLogPath -NoTypeInformation -Force
Write-Output $progress | Out-Host
Write-CustomVerbose -Message "$_.Exception.Message" -ErrorAction Stop
Set-Location $ScriptLocation
return
}
}
}
elseif (($skipMSSQL) -and ($progress[$RowIndex].Status -ne "Complete")) {
Write-CustomVerbose -Message "Operator chose to skip MySQL Hosting Server Deployment`r`n"
# Update the ConfigASDKProgressLog.csv file with successful completion
$progress[$RowIndex].Status = "Skipped"
$progress | Export-Csv $ConfigASDKProgressLogPath -NoTypeInformation -Force
Write-Output $progress | Out-Host
}
The creation of the azurestack-dbhosting resource group is tied to the MySQL deployment task, if -skipMySQL is specified then SQL Server deployment and its dependencies fails.