TemplateParameterObject Parameter in Azure Powershell New-AzureRmResourceGroupDeployment

If you’re initiating a deployment to Azure using an ARM template, then you can make use of the TemplateParameterObject to pass through a hashtable that contains the parameters for the template.

EG.

$params = @{
    clusterName = $clustername
    adminUsername = "myadmin"
    adminPassword = "myCompl000xPa%%%%wo"
    certificateThumbprint = $NewCert.Thumbprint
    sourceVaultResourceId = $vaultResourceId
    certificateUrlValue = $NewSecret.Id
    nt0InstanceCount = 3
    nodeTypeSize = "Standard_D2_v2"
    SFReverseProxyPort = 19081
}

When you come to deploy the template using Powershell, you can therefore run something like this.

$clustername="SfChallenge2018".ToLower()
$rg = Get-AzureRmResourceGroup -Name $clustername -ErrorAction SilentlyContinue

if ($rg -eq $null) {
    $rg =New-AzureRmResourceGroup $clustername -Location "WestEurope"
}

$params = @{
    clusterName = $clustername
    adminUsername = "myadmin"
    adminPassword = "myCompl000xPa%%%%wo"
    certificateThumbprint = $NewCert.Thumbprint
    sourceVaultResourceId = $vaultResourceId
    certificateUrlValue = $NewSecret.Id
    nt0InstanceCount = 3
    nodeTypeSize = "Standard_D2_v2"
    SFReverseProxyPort = 19081
}

$deployment = New-AzureRmResourceGroupDeployment -ResourceGroupName $rg.ResourceGroupName -Name $rg.ResourceGroupName `
 -TemplateFile "C:\sfHack-arm-templates\arm-templates\sf-cluster.json" `
 -TemplateParameterObject $params -Verbose

Leave a Reply

Your email address will not be published. Required fields are marked *