This article covers the steps of setting up ASP.NET Core to use Azure Key Vault.
During development, using DefaultAzureCredentials causes access errors but this issue can be resolved using ChainedTokenCredential with an application client secret.
For local development credentials, Azure.Identity and Azure.Extensions.AspNetCore.Configuration.Secrets Nuget packages can be used.
The access client can be specified in the project's user secrets, allowing it to function independently of the user account and the last filter used in Visual Studio.
Using the SecretClient class from Azure.Identity, the secret from the Azure Key Vault can be used directly in the code.
AddAzureKeyVault can be used to configure the Azure Key Vault. The secret can be read anywhere in the code using the IConfiguration interface.
Using dotnet user secrets is a more efficient mechanism to use than Azure Key Vault for local development.
The client secret should not be used in production deployments, and there are better ways to secure the application's access for Key Vault. A system-assigned managed identity is the best way to implement application access in Azure in production environments.
Links to Azure and Microsoft documentation on Key Vault configuration and developers guide are provide in the article.
This set up prevents problems caused by incorrect tenants or user accounts in Visual Studio during development.