Application Insights ASP.NET Core SQL Dependency Track

10/1/2016 3:24:00 AM By Felipe Pessoto

Application Insights for ASP.NET Core doesn't support Dependency Tracking:

Dependency tracking and performance counter collection are by default enabled in ASP.NET Core on .NET Framework (currently not supported in .NET Core) 

So I created this library to automatically track your SQL queries and send to Application Insights.


1-) Add Fujiy.ApplicationInsights.AspNetCore.SqlTrack package

2-) On your Configure method, add TelemetryClient parameter and add AiEfCoreLoggerProvider to ILoggerFactory:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, TelemetryClient tc)
    loggerFactory.AddProvider(new AiEfCoreLoggerProvider(tc));

Then you can monitor the sql calls in each request and the most expensives: