Reputation: 4352
For some reason Application Insights is not tracking SQL queries executed by my Azure Function. I have the following packages installed:
Version 3
netcoreapp3.1
I can see calls to blob storage and HTTP calls but SQL is out the mix.
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.17.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.17.0" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.10" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
Host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"dependencyTrackingOptions": {
"enableSqlCommandTextInstrumentation": true
},
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
},
"logLevel": {
"default": "Information"
}
}
}
EDIT
Finally got this to work with host.json
settings added but its not grouping the telemetry data. What I mean is, the SQL calls are being tracked seperately independent from the request. Usally you get a nice view and all dependencies are tracked as a group but this is no longer the case.
Upvotes: 2
Views: 1791
Reputation: 15906
Enabling application insights by click Application insights
blade and turn the button to enable
in azure function page,
then we can got dependency for sql query by default.
But if we wanna to see sql command in app insights when using function, we need to do further configuration, that is adding "enableSqlCommandTextInstrumentation": true
in host.json.
Here's my host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"dependencyTrackingOptions": {
"enableSqlCommandTextInstrumentation": true
},
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
And after changing the file, we can see text command in app insighs.
Upvotes: 4