Azure Resource Manager Templates (more commonly known as ARM Templates) serve as a very handy tool for Cloud Engineers. ARM Templates allow you to automate resource deployment in Azure in a “cookie-cutter” type of approach i.e. they are just scripts instructing Azure what resources to deploy and how.
ARM Templates support a concept called Linked Templates. As the name suggests, a linked template is basically an ARM Template stored in a storage location that is linked to via it’s URI into the main template as a resource deployment. This also makes the linked template a sub template of the main template. When using linked templates, there are a few things that need to be taken into consideration; this article will focus on referencing with Linked Templates.
When referencing an external source, i.e. a resource from a sub template (this is especially the case when one resource is dependent on another resource) then make sure the resource type is concatenated to the resource name; if we were to have a data factory resource depend on a storage account (from a sub template) for it’s data set then just defining the storage account name as a parameter in the file will not suffice. When writing the code for the ‘dependsOn’ clause, it would have to have the resource type appended to it like below:
dependsOn: “[concat(‘Microsoft.Storage/Accounts/’, parameters(‘stroageAccountName’))]”
Having just the storageAccountName will error as the template needs to know where to look and what to look for. Also, if we had a storage Account and Data Lake Store with the same name, this would introduce a level of ambiguity into the template, causing it to error on deployment.
Be careful when referencing in ARM Templates. It is not possible to reference a resource from a sub template parameter, instead the parameter will need to be added to the current working template (with the same name). Even though you have the linked template reference, the parameters can’t be pulled in via output referencing as ARM Templates do not support inheritance. It can be argued that this is repetition of parameter definition but (currently) this is the only way to reference sub template parameters.
%d bloggers like this: