Search code examples
azureazure-keyvaultazure-rm-templateazure-vm-templates

Use Key Vault in Azure Arm Template


I'm creating a simple ARM template to create a VM. For the "adminPassword" I'm using KeyVault (already configurated and with all the permissions in place). Here there is the relevant part of the code:

      "adminPassword":{
      "reference":{
        "keyVault":{
           "id":"/subscriptions/d68628be-2a30-5d26-94c2-3d0145fb8e3e/resourceGroups/armtemplate/providers/Microsoft.KeyVault/vaults/keyvaultfortemplate"
        },
        "secretName":"vmpassword"
     }

  }

Finally when I'm ready to start the deployment, I see it didn't get the "secret".

Click here to see the empty password field on the portal

Seems it couldn't retrive it from the KeyVault. Any idea? Thanks


Solution

  • When you pass a sensitive value as a parameter, store the value in a key vault, and reference the key vault in your parameter file. The sensitive value is securely retrieved during the deployment that's why you are not able to see the value on the portal.

    Deploy the template using Cloud Shell from the Azure portal or using the PowerShell that uses the Parameters file while deploying the template. You can use this link to deploy the template that integrate Azure Key Vault.

    Hope this helps!