Search code examples
azureentity-framework-coreblazor-server-sideazure-application-insights

Application Insights sometimes does not show the query from a SQL call


I have a Blazor server application with 2 databases it calls via Entity Frameworks. One is the Identity Library DB. The other is my application DB.

When I go in to Application Insights and:

  1. Click on the Application map
  2. Click on the SQL Server (2)
  3. Click Investigate performance

It now under Dependency Name lists the 2 databases.

  1. I select one of the dependencies
  2. I click Drill into

Now over on the right it has Select a sample dependency

If I click on one from the Identity Library database, on the right it has:

  1. Dependency Properties
  2. Custom properties
  3. Command - this has the query run
  4. Related Items

But if I click on one from the application database, then over on the right, for the command, it has the following:

louishowe.database.windows.net,1433 | Application_2024_04_25

That's the server & database. But no query. Why not? What do I have to do so Application Insights can show me the actual queries?


Solution

  • Full SQLQuery is not collected by default, and requires explicit opt-in. The following doc has instructions on how to do that: https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-dependencies#advanced-sql-tracking-to-get-full-sql-query