0

I am struggling to find documentation for this.. Here's what I have:

  1. I have a working keyvault
  2. I am not entirely sure I am using the correct terms, but I want to use the account logged in VS to access the KV. I think that may be called DefaultAzureCredentials.
  3. I've done this before in various dev environments - but it was always been through existing infrastructure. I am working with the basic azure libraries
  4. What I am used to, is the ability to define the KV URL as an env-var and then tell the secret provider what keys it needs to populate (this is another configuration provider).
  5. Not sure if needed or not, but I added the KV as a connected service to my csproj
  6. My asp.net project was created automatically for 7.0 and does not use the < Start > mechanism, instead it's creating a WebApplication.CreateBuilder().

I am not entirely sure what comes "out of the box" and what needs to be coded.

I have found this: Use keyvault However, it seems to suggest using a local keyvault. And I could not find ways of doing this in WebApplication.CreateBuilder(). It seems like if I could get an IConfigurationBuilder, I'd be able to use some of the extension methods found in Azure.Extensions.AspNetCore.Configuration.Secrets to connect, but I can't even figure out how to get that in .net7.

Shahar Prish
  • 4,838
  • 3
  • 26
  • 47
  • `.ConfigureAppConfiguration((ctx, builder) => builder.AddAzureKeyVault(url, new DefaultAzureCredentials())` or `builder.Configuration.AddAzureKeyVault` https://learn.microsoft.com/en-us/aspnet/core/security/key-vault-configuration?view=aspnetcore-7.0 Though that will override all config with any secrets. Not sure how you would filter the config values. – Jeremy Lakeman Mar 05 '23 at 23:56

1 Answers1

0

I assume you don't need the real Azure Key Vault (and the real secrets, keys, certificates in it) and you just want to be able to convince your application/tests that you have a Key Vault while running them locally.

If this is the case, you could even consider using a test double that can fake the Azure Key Vault API. If interested, please check out these:

Esta Nagy
  • 219
  • 2
  • 9