Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configuration.AzureKeyVault long to load when having dependency on Microsoft.Azure.ServiceBus #1218

Closed
Hartdrooz opened this issue Mar 5, 2019 · 5 comments
Milestone

Comments

@Hartdrooz
Copy link

Describe the bug

When I have a dependency on the nuget package Microsoft.Azure.ServiceBus and I use the extension of Azure Key Vault in the package Microsoft.Extensions.Configuration.AzureKeyVault it takes around 30 seconds to start my application. I am building rest api using .Net Core 2.2.

This bug seems to occurs when I execute the application inside Visual Studio 2017, if I run my application using docker I see a lot of logging to retrieve the token for Azure Key Vault but it doesn't take 30 seconds to have the application ready.

To Reproduce

Create a new web api project with Visual Studio using .Net Core 2.2

Add the nuget package Microsoft.Azure.ServiceBus and Microsoft.Extensions.Configuration.AzureKeyVault in the project.

In the Program.cs file configure the CreateWebHostBuilder method this way:

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .ConfigureAppConfiguration((context, builder) => 
            {
                var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
                builder.SetBasePath(Directory.GetCurrentDirectory())
                       .AddJsonFile("appsettings.json",
                                     optional: false,
                                     reloadOnChange: true)
                       .AddJsonFile($"appsettings.{env}.json",
                                     optional: true,
                                     reloadOnChange: true)
                       .AddEnvironmentVariables();

                IConfigurationRoot configuration = builder.Build();

                string keyVaultEndpoint = configuration["KeyVaultEndpoint"];

                string clientId = configuration["ClientID"];
                string clientSecret = configuration["ClientSecret"];

                builder.AddAzureKeyVault(keyVaultEndpoint, clientId, clientSecret);

            });

Expected behavior

The application should not take around 30 seconds to be ready only because of the Service.Bus package.

@martincostello
Copy link
Member

Do you have a lot of secrets in your key vault? I noticed there was a change to load these in parallel for 3.0, presumably to speed things up: #944

@Hartdrooz
Copy link
Author

No I have only like 10 secrets and I notice the behavior I have is only when I add the Service.Bus nuget package. Why I found this is because I was having two web api one without the service bus nuget package and the other with.

@TraGicCode
Copy link

While we are not using azure service bus we are in AKS and notice it also takes around 40-50 seconds for the Azure Key Vault Configuration Provider to initialize which is way to long. We only have 1 secret in our vault

Any Updates on this?

@ajcvickers ajcvickers added this to the Backlog milestone Apr 18, 2019
@rosponda57
Copy link

Hi, we have the same problem.
Maybe You have some updates for this issue?

@analogrelay
Copy link

The Azure SDK team is releasing new integration packages which work in apps using 2.1 or higher (see aspnet/Announcements#408 for details). We recommend converting to use those and filing relevant issues on https://github.com/Azure/azure-sdk-for-net/

@ghost ghost locked as resolved and limited conversation to collaborators May 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants