title: How to fix "Microsoft.Azure.KeyVault.Models.KeyVaultErrorException: 'Operation returned an invalid status code 'NotFound''"
body: <p>I am trying to get the values from my Azure Key vault in ASP.net 5 Web API application. But faced with this issue.</p>
  <p><a href="https://i.stack.imgur.com/QqVNS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QqVNS.png" alt="enter image description here" /></a></p>
  <p>I have added this code in Program.cs file</p>
  <pre><code>public class Program
  {
      public static void Main(string[] args)
      {
          CreateHostBuilder(args).Build().Run();
      }
  
      public static IHostBuilder CreateHostBuilder(string[] args) =&gt;
          Host.CreateDefaultBuilder(args)
              .ConfigureWebHostDefaults(webBuilder =&gt;
              {
                  webBuilder.UseStartup&lt;Startup&gt;();
              })
          .ConfigureAppConfiguration((context, config) =&gt;
          {
              var builtConfig = config.Build();
              var vaultName = builtConfig[&quot;keyvault&quot;];
  
              var keyVaultClient = new KeyVaultClient(
                  async (authoriy, resource, scope) =&gt;
                  {
                      var credential = new DefaultAzureCredential(false);
                      var token = credential.GetToken(
                              new TokenRequestContext(
                                  new[] {&quot;https://vault.azure.net/.default&quot; }
                                  )
                          );
                      return token.Token;
                  });
              config.AddAzureKeyVault(
                  vaultName,
                  keyVaultClient,
                  new DefaultKeyVaultSecretManager());
          });
  </code></pre>
  <p>In appsettings.json file, I gave the key-vault URL like this.</p>
  <pre><code>&quot;Keyvault&quot;: &quot;https://&lt;&lt;vaultName&gt;&gt;.vault.azure.net/.default&quot;
  </code></pre>
  <p>And I have created the Secret with the name &quot;StorageConnectionString&quot; I am using in my Class in the Azure Key-vault.</p>
  <pre><code>public BlobContainerProvider(IConfiguration configuration) 
      {
          
          string connectionString = configuration.GetValue&lt;string&gt;(&quot;StorageConnectionString&quot;);
  
          blobServiceClient = new BlobServiceClient(connectionString);
      }
  </code></pre>
  <p>Thanks in Advance.</p>