Cristian E.
Cristian E.

Reputation: 3573

ARM Templates - Explain "reference: {}" property under parameters section

I have seen examples like this:

....
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
  "keyVaultSecretValue": {
    "reference": { <===========  Reference property
      "keyVault": {
        "id": "...."
      },
      "secretName": "...."
    }
  }
},
....

I can't find any documentation on possible usages of this reference property.

Would I be able to use it for eg: Referencing a linkedTemplate's output variables?

As such:

[reference('sqlServerLinkedTemplate').outputs.connectionString.value]

Or other kind of references?

Upvotes: 0

Views: 62

Answers (1)

Martyn C
Martyn C

Reputation: 1139

In your example at the top, reference refers to the Key Vault you want to add the secret to. An example of this is shown here:

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "adminLogin": {
        "value": "exampleadmin"
    },
    "adminPassword": {
        "reference": {
        "keyVault": {
        "id": "/subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.KeyVault/vaults/<vault-name>"
        },
        "secretName": "ExamplePassword"
        }
    },
    "sqlServerName": {
        "value": "<your-server-name>"
    }
}
}

Linking templates together is done by either nesting templates together or by linking them together. The documentation has great information on this.

An example of a linked template is shown below:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "variables": {},
    "resources": [
    {
        "type": "Microsoft.Resources/deployments",
        "apiVersion": "2019-10-01",
        "name": "linkedTemplate",
        "properties": {
        "mode": "Incremental",
        "templateLink": {
            "uri":"https://mystorageaccount.blob.core.windows.net/AzureTemplates/newStorageAccount.json",
            "contentVersion":"1.0.0.0"
        }
        }
    }
    ],
    "outputs": {
    }
}

Upvotes: 1

Related Questions