Skip to content

Commit 7499272

Browse files
committed
update the key vault tutorial
1 parent c14705b commit 7499272

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed
Loading

articles/azure-resource-manager/templates/template-tutorial-use-key-vault.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
title: Use Azure Key Vault in templates
33
description: Learn how to use Azure Key Vault to pass secure parameter values during Resource Manager template deployment
44
author: mumian
5-
ms.date: 05/23/2019
5+
ms.date: 04/16/2020
66
ms.topic: tutorial
77
ms.author: jgao
88
ms.custom: seodec18
99
---
1010

1111
# Tutorial: Integrate Azure Key Vault in your ARM template deployment
1212

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).
1414

1515
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.
1616

@@ -28,8 +28,6 @@ This tutorial covers the following tasks:
2828
2929
If you don't have an Azure subscription, [create a free account](https://azure.microsoft.com/free/) before you begin.
3030

31-
[!INCLUDE [updated-for-az](../../../includes/updated-for-az.md)]
32-
3331
## Prerequisites
3432

3533
To complete this article, you need:
@@ -44,7 +42,7 @@ To complete this article, you need:
4442

4543
## Prepare a key vault
4644

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:
4846

4947
* 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.
5048
* Adds a secret to the key vault. The secret stores the VM administrator password.
@@ -67,14 +65,16 @@ $templateUri = "https://raw.githubusercontent.com/Azure/azure-docs-json-samples/
6765

6866
New-AzResourceGroup -Name $resourceGroupName -Location $location
6967
New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri -keyVaultName $keyVaultName -adUserId $adUserId -secretValue $secretValue
68+
69+
Write-Host "Press [ENTER] to continue ..."
7070
```
7171

7272
> [!IMPORTANT]
7373
> * 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).
7474
> * 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).
7676
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:
7878

7979
```json
8080
/subscriptions/<SubscriptionID>/resourceGroups/mykeyvaultdeploymentrg/providers/Microsoft.KeyVault/vaults/<KeyVaultName>
@@ -103,13 +103,14 @@ Azure Quickstart Templates is a repository for ARM templates. Instead of creatin
103103
```
104104

105105
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:
107107
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).
108+
* [**Microsoft.Storage/storageAccounts**](/azure/templates/Microsoft.Storage/storageAccounts).
109+
* [**Microsoft.Network/publicIPAddresses**](/azure/templates/microsoft.network/publicipaddresses).
110+
* [**Microsoft.Network/networkSecurityGroups**](/azure/templates/microsoft.network/networksecuritygroups).
111+
* [**Microsoft.Network/virtualNetworks**](/azure/templates/microsoft.network/virtualnetworks).
112+
* [**Microsoft.Network/networkInterfaces**](/azure/templates/microsoft.network/networkinterfaces).
113+
* [**Microsoft.Compute/virtualMachines**](/azure/templates/microsoft.compute/virtualmachines).
113114
114115
It's helpful to have some basic understanding of the template before you customize it.
115116

@@ -123,7 +124,7 @@ Azure Quickstart Templates is a repository for ARM templates. Instead of creatin
123124

124125
## Edit the parameters file
125126

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.
127128
128129
1. In Visual Studio Code, open *azuredeploy.parameters.json* if it's not already open.
129130
1. Update the `adminPassword` parameter to:
@@ -140,7 +141,7 @@ You don't need to make any changes to the template file.
140141
```
141142

142143
> [!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).
144145

145146
![Integrate key vault and Resource Manager template virtual machine deployment parameters file](./media/template-tutorial-use-key-vault/resource-manager-tutorial-create-vm-parameters-file.png)
146147

0 commit comments

Comments
 (0)