title: What is better was to load Azure Key Vault Secrets in .Net Core?
body: <p>We have stored connectionstring values in Azure Key Vault. I have read two ways to get the secret value from my .net core application.
  One is to load all secrets in ConfigurationManager using the following code:</p>
  <pre><code>var keyVaultUrl = builder.Configuration[&quot;KeyVaultUrl&quot;];
  builder.Host.ConfigureAppConfiguration(builder =&gt;
  {
      builder.AddAzureKeyVault(new Uri(keyVaultUrl), new DefaultAzureCredential());
  });
  </code></pre>
  <p>Other way is to use following code and get the secret value:</p>
  <pre><code>string keyVaultName = Environment.GetEnvironmentVariable(&quot;KEY_VAULT_NAME&quot;);
  var kvUri = &quot;https://&quot; + keyVaultName + &quot;.vault.azure.net&quot;;
  
  var client = new SecretClient(new Uri(kvUri), new DefaultAzureCredential());
  var secret = await client.GetSecretAsync(secretName);
  </code></pre>
  <p>Save these values once in static class and use throughtout the application whenever required.</p>
  <p>Which option suits better in what situation.</p>
  <p>Also provide some inputs on Reloading the secret value if it changes.</p>
  <p>I only have couple of secrets in my aaplication</p>