4

my app is asimple dotnetcore app, at CreateWebHostBuilder i have added AddAzureKeyVault with url, clientid and secret,

after moving from appsettings.json to AddAzureKeyVault i have noticed a minimum 15 sec delay in the application loading

stuck with it for a week now and not able to reduce the timedelay,

thanks in advance (desperate for a solution)

public static IWebHostBuilder CreateWebHostBuilder(string[] args) {
 var app = WebHost.CreateDefaultBuilder(args)
  .ConfigureAppConfiguration((context, builder) => {


   builder.AddAzureKeyVault($ "https://{azureVault}.vault.azure.net/", azureClientId, azureClientSecret);
   var watch = System.Diagnostics.Stopwatch.StartNew();
   config = builder.Build();
   watch.Stop();

  })
  .UseStartup < Startup > ();

 return app;
}
  • Will you deploy your app in Azure App Service in the end? If so, you can use this instead maybe: https://learn.microsoft.com/de-de/azure/app-service/app-service-key-vault-references (I know that does not answer your question itself, thus I didn't post it as an answer ;) ) – silent May 03 '19 at 15:52
  • thank you, but this service ll be deployed in bare-metal, – R.Rajesh Swamy Kumar May 06 '19 at 03:03

1 Answers1

0

First of all , from your question description i am guessing that your web app doesnt' have "Enable Always On".

By default, web apps are unloaded if they are idle for some period of time. This lets the system conserve resources. In Basic or Standard mode, you can enable Always On to keep the app loaded all the time.

Secondly, Key Vault access needs to be called from an async task, because there might be a delay in the add operation.

private async Task<string> GetKeyVaultSecretValue(varSecretParms) {

try something similar and see if it helps.

Mohit Verma
  • 5,140
  • 2
  • 12
  • 27
  • dependent on number of calls the key vault may be throttled at some point if a large number, if so might be better investigating using MSI – Mark West May 06 '19 at 16:08