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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With