I will explain an ARM template deployment error “The language expression property ‘templateLink’ doesn’t exist” and how I resolved it. My ARM template is using a linked template to call out to provision an Azure Key vault.
The following is the ARM template snippet from my main template calling out to the linked template:
1 2 3 4 5 6 7 8 9 10 11 12 | {
"apiVersion": "2018-05-01",
"name": "linkedTemplate",
"type": "Microsoft.Resources/deployments",
"properties": {
"mode": "Incremental",
"templateLink": {
"uri": "[uri(deployment().properties.templateLink.uri, 'azuredeploy-rkazurekeyvault.json')]",
"contentVersion": "1.0.0.0"
},
"parameters": {
…
|
I deploy with the following PowerShell:
| 1 2 | $resourceGroupDeployment = New-AzureRmResourceGroupDeployment -Name $resourceGroupName’Deployment’ -ResourceGroupName $resourceGroupName ` -TemplateFile .\\arm-functionapp-sql-main.json -TemplateParameterFile .\armdeploy-functionappsql.paramaters.json -DeploymentDebugLogLevel All -Mode Complete -Force |
Error:
1 2 3 4 5 6 7 8 | New-AzureRmResourceGroupDeployment : 10:43:11 PM - Resource Microsoft.Resources/deployments 'linkedTemplate' failed with message '{ "error": { "code": "InvalidTemplate", "message": "Unable to process template language expressions for resource '/subscriptions/2dac1c43-b88c-412f-8b6c-xxxxxxxxxxx/resourceGroups/rkfunctionapp-sql/providers/Microsoft.Resources/deployments/linkedTemplate' at line '338' and column '9'. 'The language expression property 'templateLink' doesn't exist, available properties are 'template, parameters, mode, debugSetting, provisioningState'.'" } }' |
Resolution:
The problem is that I am referring to my linkedTemplate in a local file folder in my computer (e.g. c:\…). It is really looking for it in a URI (or URL), that is why the template link does not exist.
This linkedTemplate Json file needs to be in an internet accessible URL such as in a github repo or in an Azure storage account. So for development purposes I find it more convenient to work with my github repos and get the URL of the RAW arm template json files
For example I would change my powershell deployment parameters with the -TemplateUri and -TemplateParamaterUri:
$resourceGroupDeployment = New-AzResourceGroupDeployment -Name $resourceGroupName’Deployment’ -ResourceGroupName $resourceGroupName `-TemplateUri ‘https://raw.githubusercontent.com/RoyKimYYZ/azuredeploy-functionapp-sql-keyvault/master/azuredeploy-functionapp-sql-main.json’ `-TemplateParameterUri https://raw.githubusercontent.com/RoyKimYYZ/azuredeploy-functionapp-sql-keyvault/master/azuredeploy-functionappsql.paramaters.json `-DeploymentDebugLogLevel All -Mode Complete -Force
Comparing between many linked template examples in the azure documentation and github samples, one can get a bit confused on connecting the dots with
- ARM template syntax “uri”: “[uri(deployment().properties.templateLink.uri
- what that URI would look like
- file location (e.g. github repo, azure storage account; not local file)
- PoweShell deployment parameters
So I hope I have cleared things up for anyone else starting out with ARM templates with linked templates that may have encountered this issue.
For background resources on Linked Templates visit
- https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-tutorial-create-linked-templates
- https://github.com/Azure/azure-docs-json-samples/blob/master/azure-resource-manager/linkedtemplates/helloworldparent.json
- https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-template-functions-deployment