0

I'm currently trying to setup Application Insights for a WebApi running on Service Fabric. While this is super easy to configure for a .NET Core application, it seems to be way more complicated for a .NET Classic application.

The official docs do only contain a rather primitive way to setup Application Insights by clicking through Visual Studio - which in the end did not work for me (it tried to add a reference to the .NET Core Nuget Package for Application Insights).

Important facts about the project

  • TargetFramework is net461
  • The application is running on Service Fabric 6.5.664.9590

What i tried so far

In my project, i referenced these three nuget packages:

  • Microsoft.ApplicationInsights.Web
  • Microsoft.ApplicationInsights.DependencyCollector

Content of the ApplicationInsights.config (I added it to the root of the project)

<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
  <TelemetryModules>
    <Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web" />
    <Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector" />
  </TelemetryModules>
  <TelemetryInitializers>
    <Add Type="Microsoft.ApplicationInsights.Web.OperationNameTelemetryInitializer, Microsoft.AI.Web" />
    <Add Type="Microsoft.ApplicationInsights.Web.OperationIdTelemetryInitializer, Microsoft.AI.Web" />
  </TelemetryInitializers>
</ApplicationInsights>

In Startup.cs, i overwrite the instrumentation key - because it differs based on the environment the application is running on (read more about that here)

public IServiceProvider ConfigureServices(IServiceCollection services)
{
     services.AddMvc();

     services.AddAuthentication(...);

     TelemetryConfiguration.Active.InstrumentationKey = _applicationInsightSettings.InstrumentationKey;
}

However - no request traces or any other information is sent to Application Insights. What am I missing?

Edit

The configuration part is working - when debugging the app, I can see that the TelemetryInitializers property in TelemetryConfiguration.Active is set to what i configured in ApplicationInsight.config. But nothing is being sent to ApplicationInsights and there are also no errors or exceptions happening.

My solution

Turns out the easiest solution was to get rid of the net461 target framework constraint. A dependency I used (a NuGet package) was limiting me to use net461. Once I got rid of that dependency, and moved the application to .NET Core and boom - everything works just magically.

CiniMod
  • 43
  • 6
  • Did you see [this](https://github.com/microsoft/ApplicationInsights-ServiceFabric) documentation too? – LoekD Jan 07 '20 at 14:41
  • Yes - I copied the example and installed the nuget packages mentioned, but it did not work. – CiniMod Jan 07 '20 at 18:50
  • Can you run on a different network to see if there might be a firewall blocking your traffic? – LoekD Jan 08 '20 at 06:36
  • I tried to run the app on different networks (home network, hotspot from my phone) but none of them worked. Also I did not get any debug outputs from ApplicationInsight - you usually get them when it send something over the network. However - i fixed it by switching to .NET Core. – CiniMod Jan 19 '20 at 10:46

0 Answers0