Skip to content

Commit 29fe931

Browse files
author
BobbySchmidt2
committed
edit pass: use-key-vault-references-dotnet-core
1 parent cbc5722 commit 29fe931

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

articles/azure-app-configuration/use-key-vault-references-dotnet-core.md

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,17 @@ ms.custom: mvc
2020
---
2121
# Tutorial: Use Key Vault references in an ASP.NET Core app
2222

23-
In this tutorial, you learn how to use the Azure App Configuration service together with Azure Key Vault. These are complementary services which are used side by side in most application deployments.
23+
In this tutorial, you learn how to use the Azure App Configuration service together with Azure Key Vault. App Configuration and Key Vault are complementary services used side by side in most application deployments.
2424

25-
To help you use the services together, App Configuration can create keys that reference values stored in Key Vault. When App Configuration does this, it stores the URI to the Key Vault value rather than the value itself. Your application retrieves the value of this key using the App Configuration client provider, just like it does for any other key stored in App Configuration. The client provider recognizes the key as a Key Vault reference and uses Key Vault to retrieve the value.
25+
App Configuration helps you use the services together by creating keys that reference values stored in Key Vault. When App Configuration creates such keys, it stores URIs to Key Vault values rather than the values themselves.
26+
27+
Your application uses the App Configuration client provider to retrieve the Key Vault values, just as it does for any other keys stored in App Configuration. Because the client provider recognizes the keys as Key Vault references, it uses Key Vault to retrieve their values.
2628

2729
Your application is responsible for authenticating properly to both App Configuration and Key Vault. The two services don't communicate directly.
2830

29-
This tutorial shows how you can implement Key Vault references in your code. It builds on the web app introduced in the quickstarts. Before you continue, finish [Create an ASP.NET Core app with App Configuration](./quickstart-aspnet-core-app.md) first.
31+
This tutorial shows you how to implement Key Vault references in your code. It builds on the web app introduced in the quickstarts. Before you continue, finish [Create an ASP.NET Core app with App Configuration](./quickstart-aspnet-core-app.md) first.
3032

31-
You can use any code editor to do the steps in this tutorial. [Visual Studio Code](https://code.visualstudio.com/) is an excellent cross-platform app that's available for the Windows, macOS, and Linux operating systems.
33+
You can use any code editor to do the steps in this tutorial. For example, [Visual Studio Code](https://code.visualstudio.com/) is a cross-platform code editor that's available for the Windows, macOS, and Linux operating systems.
3234

3335
In this tutorial, you learn how to:
3436

@@ -44,14 +46,14 @@ Before you start this tutorial, install the [.NET Core SDK](https://dotnet.micro
4446

4547
## Create a vault
4648

47-
1. Select the **Create a resource** option in the upper left corner of the Azure portal
49+
1. Select the **Create a resource** option in the upper-left corner of the Azure portal.
4850

4951
![Output after key vault creation is complete](./media/quickstarts/search-services.png)
50-
1. Go to Search and enter **Key Vault**.
52+
1. In the search box, enter **Key Vault**.
5153
1. From the results list, select **Key Vault**.
52-
1. In the **Key Vault** section, select **Create**.
53-
1. In the **Create key vault** section, provide the following information:
54-
- A unique name is required. In the **Name** box, enter **Contoso-vault2**.
54+
1. On the **Key Vault** pane, select **Create**.
55+
1. On the **Create key vault** pane, provide the following information:
56+
- In the **Name** box, enter **Contoso-vault2**. The name must be unique.
5557
- In **Subscription**, choose a subscription.
5658
- Under **Resource Group**, select **Create new** and enter a resource group name.
5759
- In the **Location** drop-down menu, choose a location.
@@ -64,7 +66,7 @@ At this point, your Azure account is the only one authorized to access this new
6466

6567
## Add a secret to Key Vault
6668

67-
To add a secret to the vault, you just need to take a couple of additional steps. In this case, add a message that you can use to test Key Vault retrieval. The message is called **Message** and you store the value of **Hello from Key Vault** in it.
69+
To add a secret to the vault, you need to take just a few additional steps. In this case, add a message that you can use to test Key Vault retrieval. The message is called **Message**, and you store the value "Hello from Key Vault" in it.
6870

6971
1. On the **Key Vault** properties pages, select **Secrets**.
7072
1. Select **Generate/Import**.
@@ -77,13 +79,13 @@ To add a secret to the vault, you just need to take a couple of additional steps
7779

7880
## Add a Key Vault reference to App Configuration
7981

80-
1. Sign in to the [Azure portal](https://portal.azure.com). Select **All resources**, and select the app configuration store instance that you created in the quickstart.
82+
1. Sign in to the [Azure portal](https://portal.azure.com). Select **All resources**, and select the App Configuration store instance that you created in the quickstart.
8183

8284
1. Select **Configuration Explorer**.
8385

8486
1. Select **+ Create** > **Key vault reference**, and then enter or select the following values:
8587
- **Key**: Select **TestApp:Settings:KeyVaultMessage**.
86-
- **Label**: Leave blank.
88+
- **Label**: Leave this value blank.
8789
- **Subscription**, **Resource group**, and **Key vault**: Enter the values corresponding to those in the key vault you created in the previous section.
8890
- **Secret**: Select the secret named **Message** that you created in the previous section.
8991

@@ -95,7 +97,7 @@ To add a secret to the vault, you just need to take a couple of additional steps
9597
az ad sp create-for-rbac -n "http://mySP" --sdk-auth
9698
```
9799
98-
This operation will return the following series of key/value pairs:
100+
This operation returns the following series of key/value pairs:
99101
100102
```console
101103
{
@@ -118,7 +120,7 @@ To add a secret to the vault, you just need to take a couple of additional steps
118120
az keyvault set-policy -n <your-unique-keyvault-name> --spn <clientId-of-your-service-principal> --secret-permissions delete get list set --key-permissions create decrypt delete encrypt get list unwrapKey wrapKey
119121
```
120122
121-
1. Add secrets for *clientId* and *clientSecret* to Secrets Manager. These commands must be executed in the same directory as the *.csproj* file.
123+
1. In the following commands, add secrets in place of *clientId* and *clientSecret* to Secrets Manager. The commands must be run in the same directory as the *.csproj* file.
122124
123125
```
124126
dotnet user-secrets set ConnectionStrings:KeyVaultClientId <clientId-of-your-service-principal>
@@ -130,14 +132,14 @@ To add a secret to the vault, you just need to take a couple of additional steps
130132
131133
## Update your code to use a Key Vault reference
132134
133-
1. Open *Program.cs*, and add references to the required packages.
135+
1. Open *Program.cs*, and add references to the following required packages:
134136
135137
```csharp
136138
using Microsoft.Azure.KeyVault;
137139
using Microsoft.IdentityModel.Clients.ActiveDirectory;
138140
```
139141
140-
1. Update the `CreateWebHostBuilder` method to use App Configuration by calling the `config.AddAzureAppConfiguration` method. Include the `UseAzureKeyVault` option, passing in a new `KeyVaultClient` reference to your Key Vault.
142+
1. Update the `CreateWebHostBuilder` method to use App Configuration by calling the `config.AddAzureAppConfiguration` method. Include the `UseAzureKeyVault` option to pass in a new `KeyVaultClient` reference to your Key Vault.
141143
142144
```csharp
143145
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
@@ -160,7 +162,9 @@ To add a secret to the vault, you just need to take a couple of additional steps
160162
.UseStartup<Startup>();
161163
```
162164
163-
1. After you've passed the `KeyVaultClient` reference to the `UseAzureKeyVault` method when initializing the connection to App Configuration, you can access the values of Key Vault references in the same way you access the values of regular App Configuration keys. To see this process in action, open *Index.cshtml* in the **Views** > **Home** directory. Replace its contents with the following code:
165+
1. When you initialized the connection to App Configuration, you passed the `KeyVaultClient` reference to the `UseAzureKeyVault` method. After the initialization, you can access the values of Key Vault references in the same way you access the values of regular App Configuration keys.
166+
167+
To see this process in action, open *Index.cshtml* in the **Views** > **Home** folder. Replace its contents with the following code:
164168
165169
```html
166170
@using Microsoft.Extensions.Configuration
@@ -180,7 +184,7 @@ To add a secret to the vault, you just need to take a couple of additional steps
180184
and @Configuration["TestApp:Settings:KeyVaultMessage"]</h1>
181185
```
182186
183-
You access the value of the Key Vault reference "TestApp:Settings:KeyVaultMessage" in the same way as the configuration value for "TestApp:Settings:Message".
187+
You access the value of the Key Vault reference **TestApp:Settings:KeyVaultMessage** in the same way as for the configuration value of **TestApp:Settings:Message**.
184188
185189
## Build and run the app locally
186190
@@ -190,24 +194,23 @@ To add a secret to the vault, you just need to take a couple of additional steps
190194
dotnet build
191195
```
192196
193-
2. After the build is successfully completed, run the following command to run the web app locally:
197+
1. After the build is successfully completed, use the following command to run the web app locally:
194198
195199
```
196200
dotnet run
197201
```
198202
199-
3. Open a browser window, and go to `http://localhost:5000`, which is the default URL for the web app hosted locally.
200-
201-
![Quickstart app launch local](./media/key-vault-reference-launch-local.png)
203+
1. Open a browser window, and go to `http://localhost:5000`, which is the default URL for the web app hosted locally.
202204
205+
![Quickstart local app launch](./media/key-vault-reference-launch-local.png)
203206
204207
## Clean up resources
205208
206209
[!INCLUDE [azure-app-configuration-cleanup](../../includes/azure-app-configuration-cleanup.md)]
207210
208211
## Next steps
209212
210-
In this tutorial, you added an Azure managed service identity to streamline access to App Configuration and improve credential management for your app. To learn more about how to use App Configuration, continue to the Azure CLI samples.
213+
In this tutorial, you added an Azure-managed service identity to streamline access to App Configuration and to improve credential management for your app. To learn more about how to use App Configuration, continue to the Azure CLI samples.
211214
212215
> [!div class="nextstepaction"]
213216
> [CLI samples](./cli-samples.md)

0 commit comments

Comments
 (0)