Skip to content

Instantly share code, notes, and snippets.

@MertSenel
Created August 22, 2020 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MertSenel/fb61beb0524970c459acc304c158d152 to your computer and use it in GitHub Desktop.
Save MertSenel/fb61beb0524970c459acc304c158d152 to your computer and use it in GitHub Desktop.
Deploy-AzARMTemplate-region5.ps1
#region Deployment ("Validate & Deploy" or "Forced" Deployment)
try {
$PromptForConfirmation = (($Force) ? $false : $true)
Write-Host "Deploying $Region"
$Deployment = New-AzResourceGroupDeployment @ARGS `
-Name "$(New-Guid)" `
-Confirm:$PromptForConfirmation `
-WhatIfResultFormat FullResourcePayloads
}
catch {
Write-Host $_.Exception.Message
exit $LASTEXITCODE
}
# Tell me If my Deployment was Successfull
if ($Deployment.ProvisioningState -eq "Succeeded") {
Write-Host "Deployed $Region Successfully"
}
# Or if there was an error during Deployment I want to know about it
elseif ($Deployment.ProvisioningState -ne "Succeeded" -and ($Deployment.CorrelationId)) {
Write-Host "$(Get-AzLog -CorrelationId $Deployment.CorrelationId)"
}
# Else just let me know if there was no AzResourceGroupDeployment Object found
elseif (!($Deployment)) {
Write-Warning "No AzResourceGroupDeployment Object Found"
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment