Azure key vault: access denied

后端 未结 6 1106
孤城傲影
孤城傲影 2020-11-29 08:25

I have the following code for obtaining a secret from the Azure key vault:

public static async Task GetToken(string authority, string resource,         


        
6条回答
  •  抹茶落季
    2020-11-29 08:49

    Access Key Vault in .Net code Azure Setting:- App Service- 1-Enable-MSI(Managed service identity)-ON

    Key Vault: 1-Open Key Vault 2-Select Access Policies from the Key Vault resource blade

    3- Click the [+ Add new] button at the top of the blade 4-Click Select Principal to select the application(App Service) you created earlier

    .Net Code:- Code to Access key vault secrets in .Net Code

     var azureServiceTokenProvider = new AzureServiceTokenProvider();
            var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
            var secret = keyVaultClient.GetSecretAsync("https://test.vault.azure.net/", "clientid").Result.Value;
    

提交回复
热议问题