Expressions
-
enclose expressions in
[] - expressions can appear anywhere in a JSON string value
- expressions return another JSON value
-
use
[[to escape - expression evaluation happens on template deployment
- question : can a parameters.json file contain an expression? My experience says no.
Parameters
-
to specify an optional parameter, provide a
defaultValue -
secureStringandsecureObjectparameter types are opaque after deployment
Variables
We can creatively use variables to create conditional logic.
Output
Output is useful for inspecting parameters during tests of the deployment.
Functions
-
Some functions are not supported in
variables. E.g.listKeysis not.
Examples
Example: conditional logic with variables.
"parameters": {
"envName": {
"type": "string",
"allowedValues": [
"test",
"prod"
]
}
},
"variables": {
"envSettings": {
"test": {
"instancesSize": "Small",
"instancesCount": 1
},
"prod": {
"instancesSize": "Large",
"instancesCount": 4
}
},
"currentEnvSettings": "[variables('envSettings')[parameters('envName')]]",
"instancesSize": "[variables('currentEnvSettings').instancesSize]",
"instancesCount": "[variables('currentEnvSettings').instancesCount]"
}
Example: output the instance size.
"outputs": {
"actualInstanceSize" : {
"type" : "string",
"value": "[variables('instanceSize')]"
}
}
See
https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authoring-templates