Variables can be accessed within other variables, resources, and outputs in the ARM template. Variables are accessed using the variables function passing the identifier for the variable.
The next code listing shows the usage of variables in the resources section. Note that arrays are accessed using their index position is square brackets.
The JSON is as follows:
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"name": "[variables('storageName')]",
"apiVersion": "[variables('api-version')[0]]",
"location": "[resourceGroup().location]",
"sku": {
"name": "[variables('storageType')]"
},
"kind": "Storage"
}
]
We will revisit variables in Chapter 4, Advance Template Features, to show the usage of the copy function along with the variables.