Specifying Azure Resource Manager parameters on the command line instead of in JSON files

Most of the Azure Resource Management template examples demonstrate using two JSON files. One file is the template definition that accepts a set of named parameters. The other file contains the parameter values.  The two files are accepted by the template engine and combined to create the actual definition.

The Azure CLI supports providing parameters in JSON files or as name/value pairs on the command line.  Parameters are always specified using --parameters. The command-line option supports two different syntaxes and can be invoked multiple times to provide property values from multiple JSON files and as command-line arguments.

The middle example represents invoking the CLI with the two filenames

The right-hand example represents involving the CLI with a template and a list of command-line parameter values. 

Refer to https://github.com/freemansoft/vnet-p2s-vpn-bastion-azure/blob/main/4-create-storage.sh

Pros and cons of JSON parameter files

  • You can check the parameter file into GitHub.  
  • You can create a parameter file for each different environment/tenant.
  • Each parameter file must provide exactly the parameters required by the template and no more. This means you can't create a common parameter file that is shared across templates. 
  • Scripts may have to construct parameter files if some of the parameter values can only be determined at invocation time.
  • Values are spread across multiple files.
  • No obvious way of inheriting parameter values from other parameter files.
Because of all this, I wanted to provide all of my parameter values as command-line arguments.

Azure CLI invoking ARM with command line parameters

This invocation submits a template by name along with 5 parameters.

az deployment group create --resource-group "$AZURE_RESOURCE_GROUP" \
     --template-file templates/template-log-analytics-workspace.json \
     --parameters \
     logAnalyticsWorkspaceName="$LOG_ANALYTICS_WORKSPACE_NAME" \

Azure Resource Management Template - Parameter fragment

This template shows a parameter definition fragment from the template-storage.json file referenced in the section above.
    "$schema""https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",    "contentVersion""",
    "parameters": {
        "lastPublishedAt": {
            "metadata": {
                "description""The last time the template was run"
        "logAnalyticsWorkspaceName": {
        "location": {
    "variables": {},
    "resources": [],
    "outputs": {}

Video Explanation

Created 2021 /09


Popular posts from this blog

Understanding your WSL2 RAM and swap - Changing the default 50%-25%

Installing the RNDIS driver on Windows 11 to use USB Raspberry Pi as network attached

DNS for Azure Point to Site (P2S) VPN - getting the internal IPs