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 issue with AzureKeyVault #1878

Closed
Yalpe opened this issue May 22, 2020 · 3 comments
Closed

Configuration issue with AzureKeyVault #1878

Yalpe opened this issue May 22, 2020 · 3 comments
Milestone

Comments

@Yalpe
Copy link

Yalpe commented May 22, 2020

Hi,

I noticed a difference in behavior in our docker services when configuring ApplicationInsights InstrumentationKey in a KeyVault using Microsoft.Extensions.Configuration.AzureKeyVault:

ServiceA (WorkerService)
ServibeB (AspNetCore)

The InstrumentationKey is null in appsettings.json and fetched from a KeyVault in our environments. The result is this:

ServiceA can fetch the Instrumentation key using this configuration:
public void ConfigureServices(IServiceCollection services) { services.AddApplicationInsightsTelemetry(); }

ServiceB can not fetch the Instrumentation key using this initialization:
public void ConfigureServices(IServiceCollection services) { services.AddApplicationInsightsTelemetry(); }

ServiceB can fetch the Instrumentation key using this initialization:
public void ConfigureServices(IServiceCollection services) { services.AddApplicationInsightsTelemetry(this.Configuration); }

Now I'm not that knowledgeable with dotnet core configurations yet but I think the problem comes from this line

. I assume that since its not using my configuration object I have to force the code to configure the options by passing in the Configuration object
services.AddApplicationInsightsTelemetry(options => AddTelemetryConfiguration(configuration, options));
.

If I compare the code to the WorkerService, I noticed that the IConfiguration is injected instead.

public DefaultApplicationInsightsServiceConfigureOptions(IConfiguration configuration = null)

Could this be why the behavior is different?

@cijothomas
Copy link
Contributor

This is known limitation of Asp.Net Core projects - it doesn't look at user IConfiguration for ikey.
Worker service SDK does this.

But this is being addressed already, and should be available the next beta version.
cc: @rajkumar-rangaraj

@cijothomas
Copy link
Contributor

@Yalpe - Btw your analysis is fully correct! thanks for spending time here, and hopefully no other customers would have to spend time on this, as we;ll have a fix for this very soon!

@cijothomas
Copy link
Contributor

will be closed by this PR by @rajkumar-rangaraj #1850

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants