Search code examples
powershellazurecontinuous-deploymentazure-resource-managerazure-rm-template

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.


Solution

  • 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