title: Azure KeyVault: Azure.Identity.CredentialUnavailableException: DefaultAzureCredential failed to retrieve a token from the included credentials
body: <p>I am trying to connect my aspnet core application that is targeting .net framework with Azure Keyvault. On a new azure vm that supports identity everything works fine, but this application is hosted on a classic azure vm that does not support identity. I made the system environment variable AzureServiceAuthConnectionString which severable other .net framework applications with Azure keyvault are already using and are working perfectly.</p>
  <p>Looking at my stdout logs I get the following exception everytime.</p>
  <blockquote>
  <p>Azure.Identity.CredentialUnavailableException: DefaultAzureCredential failed to retrieve a token from the included credentials
  EnvironmentCredential authentication unavailable. Environment variables are not fully configured
  ManagedIdentityCredential authentication unavailable, the requested identity has not been assigned to this resource.</p>
  </blockquote>
  <p>I use the following code in the startup:</p>
  <pre><code>        public static IWebHostBuilder CreateWebHostBuilder(string[] args) =&gt;
              WebHost.CreateDefaultBuilder(args)               
         .UseApplicationInsights(ConfigurationManager.AppSettings[&quot;applicationInsightsInstrumentationKey&quot;])
                  .ConfigureKestrel(options =&gt; options.AddServerHeader = false)
                  .UseIISIntegration()
                  .ConfigureAppConfiguration((context, config) =&gt;
                  {
                      var vaultName = ConfigurationManager.AppSettings[&quot;VaultName&quot;];
                      if (!string.IsNullOrEmpty(vaultName))
                      {
                          var azureServiceTokenProvider = new AzureServiceTokenProvider();
                          var keyVaultClient = new KeyVaultClient(
                              new KeyVaultClient.AuthenticationCallback(
                                  azureServiceTokenProvider.KeyVaultTokenCallback));
  
                          config.AddAzureKeyVault(
                              $&quot;https://{vaultName}.vault.azure.net/&quot;,
                              keyVaultClient,
                              new DefaultKeyVaultSecretManager());
                      }
                  })
                  .UseStartup&lt;Startup&gt;();
  </code></pre>
  <p>And in the web.config the following items :</p>
  <pre><code>   &lt;configSections&gt;
        &lt;section name=&quot;configBuilders&quot; type=&quot;System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&quot; restartOnExternalChanges=&quot;false&quot; requirePermission=&quot;false&quot;/&gt;
     &lt;/configSections&gt;
     &lt;configBuilders&gt;
      &lt;builders&gt;
        &lt;add name=&quot;AzureKeyVault&quot; vaultName=&quot;&lt;#= this.VaultName #&gt;&quot; type=&quot;Microsoft.Configuration.ConfigurationBuilders.AzureKeyVaultConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Azure, Version=2.0.0.0, Culture=neutral&quot; vaultUri=&quot;https://&lt;#= this.VaultName #&gt;.vault.azure.net&quot; /&gt;
      &lt;/builders&gt;
    &lt;/configBuilders&gt;
    &lt;connectionStrings configBuilders=&quot;AzureKeyVault&quot;&gt;
        &lt;add name=&quot;ConnectionString&quot; connectionString=&quot;&quot; providerName=&quot;System.Data.SqlClient&quot;/&gt;
    &lt;/connectionStrings&gt;
  </code></pre>