8

I am using Azure PowerShell to deploy an ARM templates but want to override a parameter in the parameters.json file at runtime

Is there a way to do this?

eg I use get-azurermresource to get the virtual network name into a variable called $vnetName I then want to pass this variable $vnetName to replace the parameters for Vnet Name in the azuredeploy.parameters.json file

1 Answer 1

9

To overwrite the paramter at runtime you can just specify it when invoking the New-AzureRmResourceGroupDeployment cmdlet:

 New-AzureRmResourceGroupDeployment `
  -TemplateFile D:\tmp\azuredeploy.json `
  -TemplateParameterFile D:\tmp\azuredeploy.json `
  -<yourParameterNameHere> $vnetName `
  -ResourceGroupName myRg

You could also permanently overwrite the json file itself using PowerShell:

$paramFile = Get-Content d:\tmp\azuredeploy.parameters.json | ConvertFrom-Json
$paramFile.parameters.vnetName.value = $vnetName 
$paramFile | ConvertTo-Json | Set-Content d:\tmp\azuredeploy.parameters.json

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.