Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions byos/app-modernization-no-sql/deploy/deployAll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ $sqlAdministratorLogin = "openhackadmin"
# Enter the SQL Server password (i.e. Password123)
$sqlAdministratorLoginPassword = "Password123"

[int]$failedEnvironments = 0
for ($i = 1; $i -le $teamCount; $i++)
{
try
Expand All @@ -34,9 +35,6 @@ for ($i = 1; $i -le $teamCount; $i++)

$rg1 = Get-AzResourceGroup -Name $resourceGroup1Name;
$rg2 = Get-AzResourceGroup -Name $resourceGroup2Name;

# Write-Output $rg1;
# Write-Output $rg2;

if ($rg1 -ne $null -and $rg2 -ne $null -and $rg1.Name -ne '' -and $rg2.Name -ne '')
{
Expand Down Expand Up @@ -71,14 +69,21 @@ for ($i = 1; $i -le $teamCount; $i++)
else
{
#report error for incorrect RG deployment
Write-Output("Deployment failed for team: " + $teamName + ". Resource Groups could not be found.");
$failedEnvironments += 1
Write-Error("Deployment failed for team: " + $teamName + ". Resource Groups could not be found.");
}
}
catch {
#report error, team deployment failure
Write-Output "An error was encountered, script could not complete: $($PSItem.ToString())";
$failedEnvironments += 1
Write-Error "An error was encountered, script could not complete: $($PSItem.ToString())";
}
}

#report operation completed
Write-Output "All resources are deployed. Enjoy the OpenHack!";
if($failedEnvironments -eq 0) {
Write-Output "All resources are deployed. Enjoy the OpenHack!";
}
else {
Write-Error "$failedEnvironments environments failed either provisioning or validation. Please check output for more details"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that I considered here was to in the error path add exit 1 to provide an opportunity for automated execution to see the execution as unsuccessful and bubble to relevant reporting. I think that's an appropriate change, but couldn't be sure of ramifications to existing processes, so I didn't include it in this round.

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Import data, run after ensure database
# Reuquies pre-defined variables: $sqlserverName, $databaseName, $sqlAdministratorLogin, $sqlAdministratorLoginPassword
# Requires pre-defined variables: $sqlserverName, $databaseName, $sqlAdministratorLogin, $sqlAdministratorLoginPassword
#

$importRequest = New-AzSqlDatabaseImport -ResourceGroupName $resourceGroup1Name `
Expand All @@ -22,5 +22,10 @@ while ($importStatus.Status -eq "InProgress") {
Start-Sleep -s 10
}

if($importStatus.Status -ne 'Succeeded') {
Write-Error "Failed to import database $databaseName for server $sqlServerName"
Write-Debug $importStatus
}

[Console]::WriteLine("")
$importStatus
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ if($availabilityResult.StatusCode -eq 200) {
Write-Output ("Website is available")
}
else {
Write-Output("Website availability check failed for team: " + $teamName)
Write-Error("Website availability check failed for team: " + $teamName)
}