-
Notifications
You must be signed in to change notification settings - Fork 285
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
Api hosted in service fabric can not pickup config #1566
Comments
services.AddApplicationInsightsTelemetry() is expected to pickup instrumentation key from appsettings.json. I don't see ikey configured in appseting.json https://github.com/AndersMalmgren/ServiceFabricLoggingRepro/blob/master/FabricApi/appsettings.json The following is an eg: with instrumentation key. |
Hi @cijothomas Service fabric does not use that json. It uses a custom configuration provider https://github.com/AndersMalmgren/ServiceFabricLoggingRepro/blob/master/FabricApi/FabricApi.cs#L45 It's populated using the service fabric settings file To test it put a breakpoint in Startup.cs you will see that it populated correctly I got this response from the service fabric team. I'm not sure its accurate though, your code correctly picks up the config in vanilla ASP Core.
|
@AndersMalmgren If SF don't use that json, AI SDK wont pickup settings. If you are configuring settings outside of the these, you need to call .AddApplicationInsightsTelemetry(Configuration) Will keep this issue as an enhancement to modify SDK to pick config from DI. |
This is false, from vanilla ASP Core I can use a custom configuration provider exactly the same way the service fabric configuration provider works and app insight will be able to pick it up without explicit supplying config instance. Edit: or am I confusing it with native logging, I will check my repro Edit: I was confusing it with native logging, native logging didn't work either until I used the CreateDefualtBuilder on the Webhost |
https://github.com/Microsoft/ApplicationInsights- aspnetcore/blob/develop/src/Microsoft.ApplicationInsights.AspNetCore/Extensions/DefaultApplicationInsightsServiceConfigureOptions.cs#L31 We only read (by default) from appsettings.json and ENV. |
Yeah I was confusing it with native logging. Yeah, much better just injecting the IConfiguration |
if injecting the IConfiguration, there is a priority issue that needs to be considered, that whether the injected IConfiguration has lower or higher priority than current default appSettings.json; It also needs to consider backwords compatibility of old behavior, otherwise it could be a breaking change. |
@chuanboz Yes agreed. At this stage, if not using the default appsettings.json, then there is workaround of supplying configuration using .AddApplicationInsightsTelemetry(Configuration) overload. |
If you are reporting bug/issue, please provide detailed Repro instructions.
Repro Steps
Using a service fabric template project, I have made a repro project here https://github.com/AndersMalmgren/ServiceFabricLoggingRepro
Configure it for app insight doing
Actual Behavior
It fails to pickup the config and log says
Application Insights Telemetry (unconfigured)
If I explicit supply it with Configuration doing
It works, but this is not how it behaves outside of service fabric.
Expected Behavior
It should work the same way as if hosted outside of service fabric
Version Info
SDK Version : 2.7.0-beta3
.NET Version : Core 2,2
How Application was onboarded with SDK(VisualStudio/StatusMonitor/Azure Extension) :
OS :
Hosting Info (IIS/Azure WebApps/ etc) : Service fabric with kestrel
The text was updated successfully, but these errors were encountered: