I have the following code, which retrieves the Secrets from KeyVault.
var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetToken));
var sec =
Is there a way I can remove from config file and fetch from anywhere else. Or is there any possible good solution to my problem.
Based on my understanding, you could store the related information into the database. And you could use the windows Authentication to access the database to get the related information.
Another way to work with a managed identity is through the Microsoft.Azure.Services.AppAuthentication.
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(
azureServiceTokenProvider.KeyVaultTokenCallback));
In this way you no need to store the related information, but you need to use azure cli to login to azure first before run the service. The AzureServiceTokenProvider
class caches the token in memory. For more detail information please refer to authenticate to custom services.