Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (40 sloc) 2.98 KB

Nested ARM template with Azure Key Vault using a dynamic id

When doing deployments to your Azure environment using an ARM template, it's quite common to use this template for adding secrets, like connection strings, to your resources also.

In order to add secrets to your resources it's advised to use a service like Azure Key Vault. Azure Key Vault enables you to add secrets to your resources, without writing them in your templates, which defeats the purpose of them being secrets.

It's rather easy to enable Azure Key Vault in your template, take a look at the following sample:

    "$schema": "",
    "contentVersion": "",
    "parameters": {
        "adminLogin": {
            "value": "exampleadmin"
        "adminPassword": {
            "reference": {
              "keyVault": {
                "id": "/subscriptions/<subscription-id>/resourceGroups/examplegroup/providers/Microsoft.KeyVault/vaults/<vault-name>"
              "secretName": "examplesecret"
        "sqlServerName": {
            "value": "<your-server-name>"


However, in this sample you need to specify a subscription id. While this isn't wrong, it's not something I like very much when doing OSS development. In a closed development environment (for example a customer), you can get away with this as you will probably deploy everything to the same subscription(s).

When doing OSS development there's no way to tell which Azure subscription people are using. Therefore you need to use a dynamic id.

I was struggling with this for quite a bit. It's explained quite well in the documentation (, but it wasn't working for me. That is, until I discovered the templateLink is only available when actually specifying an URI to a remote location. Local files aren't supported.

The contents of this repository contain a sample which is works properly. You have to specify the templateLink base URI, along with some other parameters you want to use. If everything is filled out correctly, it'll create an Azure Key Vault and an App Service which retrieves a secret value from the Key Vault.

Add support for local filesystem in the templateLink.

There's a feedback suggestion where you can vote if local files should also be supported for the use of templateLink


I'd like this to be implemented of course, so I can use the templates from the artifacts VSTS is producing for me, without having to copy the templates (per build) to some kind of (public) storage container.