How do I reference a linked ARM template that is stored in a VSTS or Azure DevOps Git Repo?

Viewed 1753

An ARM template allows you to reference another "linked" ARM template using the "templateLink" property. I would like to do this using a raw git uri in Azure DevOps (VSTS). I can do this with github as shown below:

"resources": [ 
  { 
      "apiVersion": "2017-05-10", 
      "name": "linkedTemplate", 
      "type": "Microsoft.Resources/deployments", 
      "properties": { 
        "mode": "incremental", 
        "templateLink": {
          "uri": "https://raw.githubusercontent.com/lw/BaseARMTemplates/master/ARM.json"",
          "contentVersion": "1.0.0.0"
        }, 
      } 
  }
] 
3 Answers

If your project is private, you can't. You can upload it to a public storage account (or a private storage account with a SAS token) and reference it from there.

There doesn't seem to be an API for a public project, either.

You can create a pipeline which first pushes arm-templates to private storage account and then create a step to create SAS-token and then pass the SAS-token to the ARM-template. That's the MS recommended best practise, but it feels like a hack and I didn't like it too much so I ended up creating separate release pipeline tasks and templates instead of using nested templates. If you need to pass values from template to another you can use ARM-template outputs to achieve that.

Related