Skip to content

Define template parameters#

Operational Excellence · All resources · Azure.Template.DefineParameters

Each Azure Resource Manager (ARM) template file should contain a minimal number of parameters.

Description#

Azure templates support parameters, which are inputs you can specify when deploying the template resources. Each template can support up to 256 parameters.

When defining template parameters:

  • Minimize the number of parameters that require input by specifying a defaultValue.
  • Use parameters for resource names and deployment locations.
  • Use variables or literal resource properties for values that don't change.

Recommendation#

Consider defining a minimal number of parameters to make the template reusable.

Examples#

Configure with Azure template#

To author templates that pass this rule:

  • Define at least one parameter.

For example:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "metadata": {
        "name": "Managed Identity",
        "description": "Create or update a Managed Identity."
    },
    "parameters": {
        "identityName": {
            "type": "string",
            "metadata": {
                "description": "The name of the Managed Identity."
            }
        },
        "location": {
            "type": "string",
            "defaultValue": "[resourceGroup().location]",
            "metadata": {
                "description": "The Azure region to deploy to.",
                "example": "eastus"
            }
        },
        "tags": {
            "type": "object",
            "metadata": {
                "description": "Tags to apply to the resource.",
                "example": {
                    "service": "app1",
                    "env": "prod"
                }
            }
        }
    },
    "variables": {
        "tenantId": "[subscription().tenantId]"
    },
    "resources": [
        {
            "comments": "Create or update a Managed Identity",
            "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
            "apiVersion": "2018-11-30",
            "name": "[parameters('identityName')]",
            "location": "[parameters('location')]",
            "properties": {
                "tenantId": "[variables('tenantId')]"
            },
            "tags": "[parameters('tags')]"
        }
    ]
}

Notes#

This rule is not applicable and ignored for templates generated with Bicep, PSArm and AzOps. Generated templates from these tools may not require any parameters to be set.


Last update: 2021-09-24