Skip to content

Commit 8e61306

Browse files
committed
Updated
1 parent a8f2ec7 commit 8e61306

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

articles/key-vault/general/tutorial-net-create-vault-azure-web-app.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@ To complete this quickstart:
2929
* The [.NET Core 3.1 SDK or later](https://dotnet.microsoft.com/download/dotnet-core/3.1).
3030
* [Azure CLI](/cli/azure/install-azure-cli?view=azure-cli-latest) or [Azure PowerShell](/powershell/azure/overview)
3131

32-
This quickstart assumes you are running `dotnet` and the [Azure CLI](/cli/azure/install-azure-cli?view=azure-cli-latest) in a Windows terminal (such as [PowerShell Core](/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-6), [Windows PowerShell](/powershell/scripting/install/installing-windows-powershell?view=powershell-6), or the [Azure Cloud Shell](https://shell.azure.com/)).
33-
3432
## Create a resource group
3533

3634
A resource group is a logical container into which Azure resources are deployed and managed. Create a resource group to house both your key vault and your web app with the [az group create](/cli/azure/group?view=azure-cli-latest#az-group-create) command:
3735

38-
```azurecli
36+
```azurecli-interactive
3937
az group create --name "myResourceGroup" -l "EastUS"
4038
```
4139

@@ -48,15 +46,15 @@ To create a key vault, use the [az keyvault create](/cli/azure/keyvault?view=azu
4846
> [!Important]
4947
> Each key vault must have a unique name. Replace <your-keyvault-name> with the name of your key vault in the following examples.
5048
51-
```azurecli
49+
```azurecli-interactive
5250
az keyvault create --name "<your-keyvault-name>" -g "myResourceGroup"
5351
```
5452

5553
Make a note of the returned `vaultUri`, which will be in the format"https://<your-keyvault-name>.vault.azure.net/". It will be used in the [Update the code](#update-the-code) step.
5654

5755
You can now place a secret in your key vault with the [az keyvault secret set](/cli/azure/keyvault/secret?view=azure-cli-latest#az-keyvault-secret-set) command. Set the name of your secret to "MySecret" and the value to "Success!".
5856

59-
```azurecli
57+
```azurecli-interactive
6058
az keyvault secret set --vault-name "<your-keyvault-name>" --name "MySecret" --value "Success!"
6159
```
6260

@@ -239,7 +237,7 @@ You will see the "Hello World!" message you previously saw when visiting `http:/
239237

240238
In the Azure CLI, to create the identity for this application, run the [az webapp-identity assign](/cli/azure/webapp/identity?view=azure-cli-latest#az-webapp-identity-assign) command:
241239

242-
```azurecli
240+
```azurecli-interactive
243241
az webapp identity assign --name "<your-webapp-name>" --resource-group "myResourceGroup"
244242
```
245243

@@ -255,7 +253,7 @@ The operation will return this JSON snippet:
255253

256254
To give your web app permission to do **get** and **list** operations on your key vault, pass the principalID to the Azure CLI [az keyvault set-policy](/cli/azure/keyvault?view=azure-cli-latest#az-keyvault-set-policy) command:
257255

258-
```azurecli
256+
```azurecli-interactive
259257
az keyvault set-policy --name "<your-keyvault-name>" --object-id "<principalId>" --secret-permissions get list
260258
```
261259

@@ -277,14 +275,14 @@ Find and open the Startup.cs file in your akvwebapp project.
277275

278276
Add these two lines to the header:
279277

280-
```cpp
278+
```csharp
281279
using Azure.Identity;
282280
using Azure.Security.KeyVault.Secrets;
283281
```
284282

285283
Add these three lines before the `app.UseEndpoints` call, updating the URI to reflect the `vaultUri` of your key vault.
286284

287-
```cpp
285+
```csharp
288286
var client = new SecretClient(new Uri("https://<your-unique-key-vault-name>.vault.azure.net/"), new DefaultAzureCredential());
289287

290288
KeyVaultSecret secret = client.GetSecret("mySecret");
@@ -294,7 +292,7 @@ string secretValue = secret.Value;
294292

295293
Update the line `await context.Response.WriteAsync("Hello World!");` to read:
296294

297-
```cpp
295+
```csharp
298296
await context.Response.WriteAsync(secretValue);
299297
```
300298

@@ -316,5 +314,14 @@ git push azure master
316314
http://<your-webapp-name>.azurewebsites.net
317315
```
318316

319-
Where before you saw "Hello world!", you shoukd now see the value of your secret displayed: Success!
317+
Where before you saw **Hello World**, you should now see the value of your secret displayed: **Success!**
318+
319+
## Next steps
320+
321+
- Learn more about [managed identities for Azure resources](../../active-directory/managed-identities-azure-resources/overview.md)
322+
- Learn more about [managed identities for App Service](../../app-service/overview-managed-identity.md?tabs=dotnet)
323+
- See the [Azure Key Vault client library for .NET API reference](/dotnet/api/overview/azure/key-vault?view=azure-dotnet)
324+
- See the [Azure Key Vault client library for .NET source code](https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/keyvault)
325+
- See the [v4 Azure Key Vault client library for .NET NuGet package](https://www.nuget.org/packages/Azure.Security.KeyVault.Secrets/)
326+
320327

0 commit comments

Comments
 (0)