I have a Scenario:
- Create Key vault with secret in Azure.
Access this secret in Code.
- code is working in Local(tested using Azure CLI)
- Application hosted in Azure App service(MSI enable) working fine.
- We need to Host same application on Azure VM(MSI enable) IIS server-Not working
I want the solution and suggestions for above point(Last point)
Code to Access Key vault Secret value
var azureServiceTokenProvider = new AzureServiceTokenProvider();
var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
ConfigurationApp.ClientId = keyVaultClient.GetSecretAsync("https://test.vault.azure.net/", "testid").Result.Value;
Follow this Article - https://kasunkodagoda.com/2018/04/28/allow-application-running-on-an-azure-virtual-machine-to-access-azure-key-vault-using-managed-service-identity/
https://azure.microsoft.com/en-us/resources/samples/app-service-msi-keyvault-dotnet/