Skip to content

Commit d88d379

Browse files
author
Frank Li (Wicresoft North America Ltd)
committed
Adding details to use DefaultAzureCredential.
1 parent a0cee58 commit d88d379

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,31 @@ This command shows the secret information including the URI. After completing th
103103

104104
Open Program.cs file and update the placeholder <YourKeyVaultName> with the name of your Key Vault that you created in Step 3
105105

106-
#### 7) Run the app
106+
#### 7) Set the environment variable for DefaultAzureCredential
107+
Follow one of the examples below depending on your operating system to create the environment variable. If using Windows close your open IDE or shell and restart it to be able to read the environment variable.
108+
109+
Linux
110+
111+
```bash
112+
export AZURE_CLIENT_ID="<AZURE_CLIENT_ID>"
113+
export AZURE_CLIENT_SECRET="<AZURE_CLIENT_SECRET>"
114+
export AZURE_TENANT_ID="AZURE_TENANT_ID>"
115+
```
116+
117+
Windows
118+
119+
```cmd
120+
setx AZURE_CLIENT_ID "<AZURE_CLIENT_ID>"
121+
setx AZURE_CLIENT_SECRET "<AZURE_CLIENT_SECRET>"
122+
setx AZURE_TENANT_ID "<AZURE_TENANT_ID>"
123+
```
124+
125+
#### 8) Run the app
107126
From the main menu of Visual Studio 2017, choose
108127
Debug > Start without Debugging.
109128
When the browser appears, navigate to the About page. The value for the AppSecret is displayed.
110129

111-
#### 8) Publish the web application to Azure
130+
#### 9) Publish the web application to Azure
112131

113132
1. In Visual Studio, select **key-vault-dotnet-core-quickstart** Project.
114133
2. Select **Publish** then **Start**.
@@ -117,7 +136,7 @@ This command shows the secret information including the URI. After completing th
117136
5. Select **Create**.
118137
![Publish](./media/PublishToAzure.gif)
119138

120-
#### 8) Enable Managed Service Identity
139+
#### 10) Enable Managed Service Identity
121140
Azure Key Vault provides a way to securely store credentials and other keys and secrets, but your code needs to authenticate to Key Vault to retrieve them. Managed Service Identity (MSI) makes solving this problem simpler by giving Azure services an automatically managed identity in Azure Active Directory (Azure AD). You can use this identity to authenticate to any service that supports Azure AD authentication, including Key Vault, without having any credentials in your code.
122141

123142
1. Return to the Azure CLI
@@ -130,7 +149,7 @@ az webapp identity assign --name "keyvaultdotnetcorequickstart" --resource-group
130149
>[!NOTE]
131150
>This command is the equivalent of going to the portal and switching **Managed service identity** to **On** in the web application properties.
132151
133-
#### 9) Assign permissions to your application to read secrets from Key Vault
152+
#### 11) Assign permissions to your application to read secrets from Key Vault
134153
1. Return to the Azure CLI
135154
2. Run the following commands by replacing the placeholders
136155
```

0 commit comments

Comments
 (0)