Fetching secrets from keyVault from Azure in c#

后端 未结 1 692
说谎
说谎 2021-01-24 01:21

I have the following code, which retrieves the Secrets from KeyVault.

var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetToken));
var sec =         


        
相关标签:
1条回答
  • 2021-01-24 01:57

    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.

    0 讨论(0)
提交回复
热议问题