You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-resource-manager/templates/template-tutorial-use-key-vault.md
+16-15Lines changed: 16 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,15 +2,15 @@
2
2
title: Use Azure Key Vault in templates
3
3
description: Learn how to use Azure Key Vault to pass secure parameter values during Resource Manager template deployment
4
4
author: mumian
5
-
ms.date: 05/23/2019
5
+
ms.date: 04/16/2020
6
6
ms.topic: tutorial
7
7
ms.author: jgao
8
8
ms.custom: seodec18
9
9
---
10
10
11
11
# Tutorial: Integrate Azure Key Vault in your ARM template deployment
12
12
13
-
Learn how to retrieve secrets from an Azure key vault and pass the secrets as parameters when you deploy an Azure Resource Manager (ARM) template. The parameter value is never exposed, because you reference only its key vault ID. For more information, see [Use Azure Key Vault to pass secure parameter value during deployment](./key-vault-parameter.md).
13
+
Learn how to retrieve secrets from an Azure key vault and pass the secrets as parameters when you deploy an Azure Resource Manager (ARM) template. The parameter value is never exposed, because you reference only its key vault ID. You can reference the key vault secret by using a static ID or a dynamic ID. This tutorial uses a static ID. With the static ID approach, you reference the key vault in the template parameter file, not the template file. For more information about both approaches, see [Use Azure Key Vault to pass secure parameter value during deployment](./key-vault-parameter.md).
14
14
15
15
In the [Set resource deployment order](./template-tutorial-create-templates-with-dependent-resources.md) tutorial, you create a virtual machine (VM). You need to provide the VM administrator username and password. Instead of providing the password, you can pre-store the password in an Azure key vault and then customize the template to retrieve the password from the key vault during the deployment.
16
16
@@ -28,8 +28,6 @@ This tutorial covers the following tasks:
28
28
29
29
If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
@@ -44,7 +42,7 @@ To complete this article, you need:
44
42
45
43
## Prepare a key vault
46
44
47
-
In this section, you create a key vault and add a secret to it, so that you can retrieve the secret when you deploy your template. There are many ways to create a key vault. In this tutorial, you use Azure PowerShell to deploy an [ARM template](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorials-use-key-vault/CreateKeyVault.json). This template does the following:
45
+
In this section, you create a key vault and add a secret to it, so that you can retrieve the secret when you deploy your template. There are many ways to create a key vault. In this tutorial, you use Azure PowerShell to deploy an [ARM template](https://raw.githubusercontent.com/Azure/azure-docs-json-samples/master/tutorials-use-key-vault/CreateKeyVault.json). This template does two things:
48
46
49
47
* Creates a key vault with the `enabledForTemplateDeployment` property enabled. This property must be *true* before the template deployment process can access the secrets that are defined in the key vault.
50
48
* Adds a secret to the key vault. The secret stores the VM administrator password.
> * The resource group name is the project name, but with **rg** appended to it. To make it easier to [clean up the resources that you created in this tutorial](#clean-up-resources), use the same project name and resource group name when you [deploy the next template](#deploy-the-template).
74
74
> * The default name for the secret is **vmAdminPassword**. It's hardcoded in the template.
75
-
> * To enable the template to retrieve the secret, you must enable an access policy called "Enable access to Azure Resource Manager for template deployment" for the key vault. This policy is enabled in the template. For more information about the access policy, see [Deploy key vaults and secrets](./key-vault-parameter.md#deploy-key-vaults-and-secrets).
75
+
> * To enable the template to retrieve the secret, you must enable an access policy called **Enable access to Azure Resource Manager for template deployment** for the key vault. This policy is enabled in the template. For more information about the access policy, see [Deploy key vaults and secrets](./key-vault-parameter.md#deploy-key-vaults-and-secrets).
76
76
77
-
The template has one output value, called *keyVaultId*. Write down the ID value for later use, when you deploy the virtual machine. The resource ID format is:
77
+
The template has one output value, called *keyVaultId*. You will use this ID along with the secret name to retrieve the secret value later in the tutorial. The resource ID format is:
@@ -103,13 +103,14 @@ Azure Quickstart Templates is a repository for ARM templates. Instead of creatin
103
103
```
104
104
105
105
1. Select **Open** to open the file. The scenario is the same as the one that's used in [Tutorial: Create ARM templates with dependent resources](./template-tutorial-create-templates-with-dependent-resources.md).
106
-
The template defines five resources:
106
+
The template defines six resources:
107
107
108
-
* `Microsoft.Storage/storageAccounts`. See the [template reference](https://docs.microsoft.com/azure/templates/Microsoft.Storage/storageAccounts).
109
-
* `Microsoft.Network/publicIPAddresses`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/publicipaddresses).
110
-
* `Microsoft.Network/virtualNetworks`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/virtualnetworks).
111
-
* `Microsoft.Network/networkInterfaces`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.network/networkinterfaces).
112
-
* `Microsoft.Compute/virtualMachines`. See the [template reference](https://docs.microsoft.com/azure/templates/microsoft.compute/virtualmachines).
It's helpful to have some basic understanding of the template before you customize it.
115
116
@@ -123,7 +124,7 @@ Azure Quickstart Templates is a repository for ARM templates. Instead of creatin
123
124
124
125
## Edit the parameters file
125
126
126
-
You don't need to make any changes to the template file.
127
+
By using the static ID method, you don't need to make any changes to the template file. Retrieving the secret value is done by configuring the template parameter file.
127
128
128
129
1. In Visual Studio Code, open *azuredeploy.parameters.json* if it's not already open.
129
130
1. Update the `adminPassword` parameter to:
@@ -140,7 +141,7 @@ You don't need to make any changes to the template file.
140
141
```
141
142
142
143
> [!IMPORTANT]
143
-
> Replace the value for **id** with the resource ID of the key vault that you created in the previous procedure.
144
+
> Replace the value for **id** with the resource ID of the key vault that you created in the previous procedure. The secretName is hardcoded as **vmAdminPassword**. See [Prepare a key vault](#prepare-a-key-vault).
0 commit comments