-
默认情况下,SQL集合设置为关闭。我们需要在Azure门户中启用它。
-
要获得完整的SQL查询,我们需要启用
SQL Commands
在我们部署的
App Service
=>
Application Insights
。
-
在中添加以下代码行
Program.cs
文件,如果是
.NET Core
应用程序。
builder.Services.ConfigureTelemetryModule<DependencyTrackingTelemetryModule>((module, o) => { module.EnableSqlCommandTextInstrumentation = true; });
-
如果是的话
.NET Framework
应用程序,在中添加以下行
TelemetryModules
中的部分
ApplicationInsights.config
文件(当我们在Visual Studio中添加Application Insights时生成。
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">,
<EnableSqlCommandTextInstrumentation>true</EnableSqlCommandTextInstrumentation>
</Add>
参考文献取自
MSDoc
和
GitHub
。