0
votes

The documentation on ARM templates does not show how to use different versions (at least that I can find). All I get from the document is that the contentVersion value in the templateLink and the parameterLink objects need to match the value in the linked template.

"resources": [
  {
    "type": "Microsoft.Resources/deployments",
    "apiVersion": "2018-05-01",
    "name": "linkedTemplate",
    "properties": {
    "mode": "Incremental",
    "templateLink": {
        "uri":"https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.json",
        "contentVersion":"1.0.0.0"
    },
    "parametersLink": {
        "uri":"https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.parameters.json",
        "contentVersion":"1.0.0.0"
    }
    }
  }
]

Source: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-linked-templates#external-template-and-external-parameters

Someone opened an issue on GitHub to request additional information but I still didn't get a clear picture of how to use the version. https://github.com/MicrosoftDocs/azure-docs/issues/9402

Does anyone know of any examples of how to use different contentVersion values?

1

1 Answers

2
votes

I think you may misunderstand the usage of the contentVersion , the property is just used to document changes in your template and make sure you are using the correct template, it can be any value.

See: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-authoring-templates#template-format

enter image description here

For example, if the contentVersion in the template https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.json is 2.0.0.0,

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "2.0.0.0",
    "parameters": {},
    "resources": []
}

but you use "contentVersion":"1.0.0.0" like below,

 "templateLink": {
        "uri":"https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.json",
        "contentVersion":"1.0.0.0"
    }

then you will get an error. It has been mentioned in this link:

You don't have to provide the contentVersion property for the template or parameters. If you don't provide a content version value, the current version of the template is deployed. If you provide a value for content version, it must match the version in the linked template; otherwise, the deployment fails with an error.

One day, if you make some changes to the target template, you can change the contentVersion to 3.0.0.0 to document the changes, etc. Or you do not change it. It all depends on you.