- Provisioning Azure KeyVault
- Securing connectivity to Azure Cognitive Services
- Retrieving secrets from KeyVault
This code is provided for demo purposes only for course AI-102.
- Azure Subscription
- .NET core 3.1
- VS code or VS 2019
-
Provision keyvault from Azure portal. Follow instruction from QuickStart
-
Create Service principal from Azure portal. Follow instruction from QuickStart
-
Grab
Subscription ID
,AppID
andKey
from Service principal. -
From
Access policy
of Keyvault add service principal withget
andlist
permission to secret of keyvault as explained in the tutorial.
-
Open VS code or project file in VS 2019.
-
Update
appsettings.json
with your values collected above:"AZURE_CLIENT_ID": "your service account app id", "AZURE_CLIENT_SECRET": "your service account secret", "AZURE_TENANT_ID": "your tenant id", "KeyVaultName": "short name of your keyvault", "secretName": "key"
-
Run the application by command
dotnet run
-
Observe the value on the console and compare it with the value of the secret KEY1 (
hello world
in my case).