I am trying to register my Azure client dependencies in program.cs (.Net 6)
In program.cs I have:
builder.Services.AddAzureClients(clientBuilder =>
{
clientBuilder.AddSecretClient(builder.Configuration.GetSection("akeyvaulturl"));
clientBuilder.AddBlobServiceClient(HowToGetConfigFromKeyVault).WithName("myblobserviceclient");
});
The only example I can find is: builder.AddBlobServiceClient(Configuration.GetSection("Storage"))
Which is fine if the blob service client is stored in appsettings.json etc. But what if my configuration is stored in KeyVault? I can't see anyway of providing keyvault settings as configuration.
I believe, you have to create the ClientInstance
for the BlobServiceClient Class that can bring the dependencies for integration of the Azure Key Vault Configuration libraries in .NET Core
.
Once the configuration builder instance is created/registered, we have to pass the Configuration values stored in respective Service container such as Azure Key Vault:
var appOptions = provider.GetService<IOptions<MyApplicationOptions>>();
return new SecretClient(appOptions.Value.KeyVaultEndpoint, credential, options);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.