问题
I have WebApp which I host on Azure App Service. It also uses certain values from KeyVault.
WebApp authenticates to KeyVault using Managed Service Identity of AppService and assigning the identity permissions in keyvault it works.
However, I am yet to figure out, how can I possibly get around this or perform dummy authentication when I am debugging on localhost. because localhost can't directly authenticate to keyvault.
Any ideas would be great.
回答1:
If we want to debug on the localhost, we could use Microsoft.Azure.Services.AppAuthentication to do that. For more information, please refer to this article.
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var kv = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
Note:
- If there is no Azure Services Authentication Extension installed, you could download and install the extension.
Give access Keyvault right to your account.
Login with your account
来源:https://stackoverflow.com/questions/50878643/authenticate-to-keyvault-as-dummy-app-service-identity-from-localhost