Created
August 22, 2020 03:41
-
-
Save MertSenel/fb61beb0524970c459acc304c158d152 to your computer and use it in GitHub Desktop.
Deploy-AzARMTemplate-region5.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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