title: Getting an access token for Azure Key Vault in Rider using Azure CLI
body: <p>I am currently trying to get keyvault integration in our project.
  I am running Ubuntu (FF) and working in Rider.</p>
  <p>Things i have done in order to achieve this is:</p>
  <ul>
  <li>Create an access policy for my AD user for the keyvault</li>
  <li>Installed azure cli, running <code>az login</code>, <code>az account set subscription</code></li>
  <li>Installed Azure Toolkit for Rider (not sure if this was necessary)</li>
  </ul>
  <p>I have also verified that I can get an access token through the azure cli by running <code>az account get-access-token --resource https://vault.azure.net</code></p>
  <p>When I run my app, I get this error:</p>
  <pre><code>Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/d8ed8deb-97d7-4062-a791-c45b9561ec8e. Exception Message: Tried the following 3 methods to get an access token, but none of them worked.
  Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/d8ed8deb-97d7-4062-a791-c45b9561ec8e. Exception Message: Tried to get token using Managed Service Identity. Unable to connect to the Managed Service Identity (MSI) endpoint. Please check that you are running on an Azure resource that has MSI setup.
  Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/d8ed8deb-97d7-4062-a791-c45b9561ec8e. Exception Message: Tried to get token using Visual Studio. Access token could not be acquired. Environment variable LOCALAPPDATA not set.
  Parameters: Connection String: [No connection string specified], Resource: https://vault.azure.net, Authority: https://login.windows.net/d8ed8deb-97d7-4062-a791-c45b9561ec8e. Exception Message: Tried to get token using Azure CLI. Access token could not be acquired. 
  </code></pre>
  <p>I've tried different options for the connection string, but it whatever I try it says it cannot obtain an access token. Since I've logged in with <code>az login</code> I think obtaining access to the vault should just work, but I am probably missing something.</p>
  <p>EDIT: added code</p>
  <p>I am following this guide: <a href="https://docs.microsoft.com/en-us/azure/key-vault/general/service-to-service-authentication" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/key-vault/general/service-to-service-authentication</a></p>
  <pre><code>        var tokenProvider = new AzureServiceTokenProvider();
          var client = new KeyVaultClient(
              new KeyVaultClient.AuthenticationCallback(tokenProvider.KeyVaultTokenCallback));
          var builder = new ConfigurationBuilder();
          builder.AddAzureKeyVault(config.Url, client, new DefaultKeyVaultSecretManager());
  </code></pre>
  <p>As you can see I am trying to add the secrets that are in the keyvault to a configuration.</p>