Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
subash544772 authored Sep 4, 2020
1 parent 601b4e4 commit 356c093
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions deployresourcegroup.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
param (
[string]$ResourceGroup="subashtest",
[string]$Subscription="xxxxxxxxxx",
[string]$Templatefile="xxxxxx\azuredeploy.json",
[string]$Parametersfile="xxxxxxxxx\azuredeploy.parameters.json",
[string]$administratorLoginPassword,


)

function Invoke-AzureCLI() {
& az $args
if ($LASTEXITCODE -ne 0) {
throw "AzureCLI call failed: $LASTEXITCODE"
}
}

function Get-SecretValue {
param (
[string]$VaultName="subashtest",
[string]$SecretName="administratorLoginPassword"
)
return (Invoke-AzureCLI keyvault secret show --vault-name $VaultName --name $SecretName | ConvertFrom-JSON).value
}


function Invoke-ValidateResourceGroupDeployment
{
param(
[string]$ResourceGroup,
[string]$Templatefile,
[string]$Parametersfile,
[string]$administratorLoginPassword,
[string]$Subscription
)

$administratorLoginPassword=Get-SecretValue
$result= az group deployment validate --resource-group $ResourceGroup --subscription $Subscription --template-file $Templatefile --parameters $Parametersfile --parameters adminPassword=$administratorLoginPassword
Write-Host $result

if($LASTEXITCODE -ne 0)
{
throw "Template validation failed"
}
}
function Invoke-ResourceGroupDeployment{
param(
[string]$ResourceGroup,
[string]$Templatefile,
[string]$Parametersfile,
[string]$administratorLoginPassword,
[string]$Subscription
)
$administratorLoginPassword=Get-SecretValue

$result= az group deployment create --resource-group $ResourceGroup --subscription $Subscription --template-file $Templatefile --parameters $Parametersfile --parameters adminPassword=$administratorLoginPassword
Write-Host $result

if($LASTEXITCODE -ne 0)
{
throw "Template validation failed"
}

}

Invoke-ValidateResourceGroupDeployment -ResourceGroup $ResourceGroup -Templatefile $Templatefile -Parametersfile $Parametersfile -Subscription $Subscription
Invoke-ResourceGroupDeployment -ResourceGroup $ResourceGroup -Templatefile $Templatefile -Parametersfile $Parametersfile -Subscription $Subscription

0 comments on commit 356c093

Please sign in to comment.