Search code examples
azuretemplatesazure-resource-managerazure-resource-group

How can I divide an existing template into linked Templates


Auto generated arm templates aren't meant to be production ready, they need refinement. that is expected.

How can a Devops staff divide auto generated ARM templates into Linked templates?

References

Linked Templates

https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-linked-templates

Azure ARM template deployment

https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-overview#template-deployment


Solution

  • How can a Devops staff divide auto generated ARM templates into Linked templates?

    Per my understanding, you could leverage Azure Resource Group deployment project through visual studio for a simple to divide your ARM template into Linked templates manually.

    After you created the deployment project, you could right click your deployment project and click "Add > New Item", choose "Azure Resource Manager Deployment Template", then copy/paste your existed ARM template into your azuredeploy.json, then you could enable JSON Outline window by clicking "View > Other Windows > JSON Outline", then you could choose the resources which would be divided into Linked template, then copy the related resource configurations (resource definition, variables, parameters,etc.) into a new "Azure Resource Manager Deployment Template". Here I divided the HostingPlan into a Linked template, when deploying my azure website, I would use the hosting plan linked template as follows:

    enter image description here

    enter image description here

    Deploying azure website with a host plan linked template

    enter image description here

    Azure website deployment template: https://brucechen.blob.core.windows.net/arm-templates/websitewithlinkedtemplate.json

    Then, check the latest deployment log under "SETTING > Deployments" section of your resource group as follows:

    enter image description here