Secure Azure Resource Manager Template Deployment with Azure Key Vault

Ensure Access to Secrets in Azure Key Vault (KV11597200) for Azure Resource Manager Template Deployment

Question

SIMULATION -

You need to ensure that when administrators deploy resources by using an Azure Resource Manager template, the deployment can access secrets in an Azure key vault named KV11597200.

To complete this task, sign in to the Azure portal.

Explanations

See the explanation below.

You need to configure an option in the Advanced Access Policy of the key vault.

1. In the Azure portal, type Azure Key Vault in the search box, select Azure Key Vault from the search results then select the key vault named KV11597200.

Alternatively, browse to Azure Key Vault in the left navigation pane.

2. In the properties of the key vault, click on Advanced Access Policies.

3. Tick the checkbox labelled Enable access to Azure Resource Manager for template deployment.

4. Click Save to save the changes.

To ensure that administrators can access secrets in an Azure key vault when deploying resources using an Azure Resource Manager template, you can follow the steps below:

  1. Create an Azure Key Vault:
  • Go to the Azure Portal and sign in.
  • Click on "+ Create a resource" button on the top left-hand corner of the page.
  • Search for "Key Vault" and select it from the list of results.
  • Click on "Create" button on the Key Vault page.
  • Fill in the required information for the Key Vault, including a unique name, resource group, location, pricing tier, and access policies.
  • Click "Review + create" button at the bottom of the page, and then click "Create" again to create the Key Vault.
  1. Create a Secret in the Key Vault:
  • Once the Key Vault is created, go to the Key Vault page.
  • Click on "Secrets" under the "Settings" section on the left-hand side of the page.
  • Click on "+ Generate/Import" button to create a new secret.
  • Fill in the required information for the secret, including a unique name, value, and any optional metadata.
  • Click "Create" to create the secret.
  1. Grant Access to the Key Vault:
  • In the Key Vault page, click on "Access policies" under the "Settings" section on the left-hand side of the page.
  • Click on "+ Add Access Policy" button to add a new access policy.
  • Select the "Secret Management" and "Get" permissions for the access policy.
  • Under "Select principal", search for and select the name of the Azure Resource Manager template deployment that will be accessing the Key Vault.
  • Click "Add" to save the access policy.
  1. Use the Key Vault in the Azure Resource Manager template:
  • In the Azure Resource Manager template, add a reference to the Key Vault and the secret that will be accessed.
  • For example, you can add the following code to the template:

"resources": [ { "type": "Microsoft.KeyVault/vaults/secrets", "apiVersion": "2018-02-14", "name": "[concat(parameters('vaultName'), '/', parameters('secretName'))]", "properties": { "value": "[reference(concat('Microsoft.KeyVault/vaults/', parameters('vaultName')), '2018-02-14').secrets[parameters('secretName')].value]" } } ]

  • In this code, replace "vaultName" with the name of the Key Vault, and "secretName" with the name of the secret.

Once these steps are completed, the Azure Resource Manager template deployment should be able to access the secret in the Key Vault.