Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 944
Phish Avatar asked Mar 07 '23 20:03

Phish


1 Answers

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

like image 191
4c74356b41 Avatar answered Apr 29 '23 11:04

4c74356b41