Skip to content

Commit

Permalink
Fixed runtime error when registering ApplicationInsights. Closes #53
Browse files Browse the repository at this point in the history
  • Loading branch information
jezzsantos committed Oct 16, 2024
1 parent ebe12b0 commit 8753c6f
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public static WebApplication ConfigureApiHost(this WebApplicationBuilder appBuil
WebHostOptions hostOptions)
{
var services = appBuilder.Services;
#if HOSTEDONAZURE
// HACK: We need to add this dependency before registering any keyed dependencies, for ApplicationInsights v2.22.0.
// See https://github.com/microsoft/ApplicationInsights-dotnet/issues/2879
services.AddApplicationInsightsTelemetry();
#endif
RegisterSharedServices();
RegisterConfiguration(hostOptions.IsMultiTenanted);
RegisterRecording();
Expand Down Expand Up @@ -171,8 +176,6 @@ void RegisterRecording()
#else
#if HOSTEDONAZURE
loggingBuilder.AddApplicationInsights();
services.AddApplicationInsightsTelemetry();
#elif HOSTEDONAWS
loggingBuilder.AddLambdaLogger();
#endif
Expand Down

0 comments on commit 8753c6f

Please sign in to comment.