user2703728
user2703728

Reputation:

Azure ARM deployment, passing dynamic variables from powershell

I have created an ARM template to deploy a service with a set of application settings. One of my parameters in the ARM template does not have a default value. At present, when I run the deployment script using ISE I am asked "Supply values for the following parameters:" (a request for human input).

This is fine but this script will be automated. How do I pipe this dynamic variable into this field?

ARM:

"Paramters":{
    "dynamicParam": {
        "type": "string",
        "metadata": {
            "description": "dont know this until deployment"
        }
    }
}

The deployment powershell is boiler plate.

Upvotes: 4

Views: 4151

Answers (3)

Sachin Kalia
Sachin Kalia

Reputation: 1107

There is simplest and right way to pass dynamic argument in Az powershell while you create resource deployment through ARM templates .

Kindly use the below cmdlet to achieve that.

az group deployment create --name TempGroup --resource-group insightsrg --parameters '{\"actionGroupName\": {\"value\": \"jsonActionGroup\"},\"actionGroupShortName\": {\"value\": \"JAG\"}}' --template-file "C:\HM\ARM\policy\actiongroup\actiongroup.json"

Upvotes: -2

Hemant Sakta
Hemant Sakta

Reputation: 685

Just want to add to above answer use -TemplateParameterObject to pass $params

New-AzureRmResourceGroupDeployment -ResourceGroupName $resourceGroupName -Name $deploymentName -TemplateFile $templateFilePath -TemplateParameterObject $params;

Upvotes: 1

4c74356b41
4c74356b41

Reputation: 72171

There are several ways to do that, easiest one is this:

New-AzureRmResourceGroupDeployment ... -dynamicParam value

another one (which is cooler) is to create a hash table with the values of parameters you have and splat it against the cmdlet:

$params = @{
   paramA = "test"
   paramB = "anotherTest"
}
New-AzureRmResourceGroupDeployment ... @params

Another way is to preprocess the json parameters file and pass it to the deployment

Upvotes: 8

Related Questions