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/key-vault/general/tutorial-net-create-vault-azure-web-app.md
+18-11Lines changed: 18 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,13 +29,11 @@ To complete this quickstart:
29
29
* The [.NET Core 3.1 SDK or later](https://dotnet.microsoft.com/download/dotnet-core/3.1).
30
30
*[Azure CLI](/cli/azure/install-azure-cli?view=azure-cli-latest) or [Azure PowerShell](/powershell/azure/overview)
31
31
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
-
34
32
## Create a resource group
35
33
36
34
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:
37
35
38
-
```azurecli
36
+
```azurecli-interactive
39
37
az group create --name "myResourceGroup" -l "EastUS"
40
38
```
41
39
@@ -48,15 +46,15 @@ To create a key vault, use the [az keyvault create](/cli/azure/keyvault?view=azu
48
46
> [!Important]
49
47
> Each key vault must have a unique name. Replace <your-keyvault-name> with the name of your key vault in the following examples.
50
48
51
-
```azurecli
49
+
```azurecli-interactive
52
50
az keyvault create --name "<your-keyvault-name>" -g "myResourceGroup"
53
51
```
54
52
55
53
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.
56
54
57
55
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!".
58
56
59
-
```azurecli
57
+
```azurecli-interactive
60
58
az keyvault secret set --vault-name "<your-keyvault-name>" --name "MySecret" --value "Success!"
61
59
```
62
60
@@ -239,7 +237,7 @@ You will see the "Hello World!" message you previously saw when visiting `http:/
239
237
240
238
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:
241
239
242
-
```azurecli
240
+
```azurecli-interactive
243
241
az webapp identity assign --name "<your-webapp-name>" --resource-group "myResourceGroup"
244
242
```
245
243
@@ -255,7 +253,7 @@ The operation will return this JSON snippet:
255
253
256
254
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:
257
255
258
-
```azurecli
256
+
```azurecli-interactive
259
257
az keyvault set-policy --name "<your-keyvault-name>" --object-id "<principalId>" --secret-permissions get list
260
258
```
261
259
@@ -277,14 +275,14 @@ Find and open the Startup.cs file in your akvwebapp project.
277
275
278
276
Add these two lines to the header:
279
277
280
-
```cpp
278
+
```csharp
281
279
usingAzure.Identity;
282
280
usingAzure.Security.KeyVault.Secrets;
283
281
```
284
282
285
283
Add these three lines before the `app.UseEndpoints` call, updating the URI to reflect the `vaultUri` of your key vault.
0 commit comments