【App Service】常规排查 App Service 启动 Application Insights 无数据的步骤 (.NET版本)

问题描述

Application Insights(应用服务见解)是非常有用的日志分析工具,当应用部署在App Service后,通过Codeless的方式启动Application Insights服务,能轻松查看应用的状态并主动收集异常完整信息。

但是,常常会因为各种原因导致Application Insights没有日志数据的情况。

本文将从 网络限制 ,加载Application Insights模块 ,DLL冲突三个方面来查看没有数据的情况。

问题解答

第一:先从网络的连通性进行判断

在App Service的门户页面中,选择网络(Networking)页面

点击(Troubleshooting)按钮,进入如下图的 Diagnostic Tools页面

选择Network Troubleshooter工具,在出现的页面中,设置Destination type为 specify manually, URI or IP:Port值则输入:https://chinanorth3-0.in.applicationinsights.azure.cn/v2/track (注:所有中国区Azure的Application Insights都是这个地址)

这个操作会检查很多内容:比如DNS解析,443端口是否ping通,App Service所在的虚拟网络NSG等规则,如有任何失败的信息,就需要基于错误提示针对性解决。

如果全部检查成功,则可以得出结论:App Service到Application Insights之间的网络畅通。

第二:从App Service的w3wp.exe进程是否加载了Application Insights模块

进入App Service的Kudu站点中(https://<your app service name>.scm.chinacloudsites.cn/ProcessExplorer/)中的Process Explorer页面

查看w3wp.exe 进程的modules信息,检查其中是否包含了ApplicationInsights的相关dll文件

如果在w3wp.exe中没有发现app insights dll相关加载,则表示有不支持的情况发生( 比如 Application Insights Auto-Instrumentation 不支持 IIS Classic Pipeline 模式 )。

在App Service中,可以通过配置页面查看是否设置:

除此之外,就需要考虑是否有DLL冲突的问题,可以参考第三步。

第三:是否存在DLL冲突

进入App Service中自带的Application Insights状态查看页面(https://<your app service name>.scm.chinacloudsites.cn/ApplicationInsights)

如果第二步中,无法加载Application Insights的dll, 则这个页面会看见报错:Cannot retrieve Application Insight's attach status.

如果第二步中的内容加载成功,则可以查看到Application Insights的状态值:

当然,这里必须注意下列的三个值:

  1. AppAlreadyInstrumented
  2. AppContainsDiagnosticSourceAssembly
  3. AppContainsAspNetTelemetryCorrelationAssembly

如以上三个值存在,则代表DLL冲突,必须删除应用中所包含的如下DLL

  1. Microsoft.ApplicationInsights
  2. System.Diagnostics.DiagnosticSource
  3. Microsoft.AspNet.TelemetryCorrelation.

参考官方文档说明:https://learn.microsoft.com/en-us/troubleshoot/azure/azure-monitor/app-insights/telemetry/troubleshoot-app-service-issues?tabs=net%2Cnet-1%2Cnet-2%2Cpython-3

Confirm that there are no entries for AppAlreadyInstrumented, AppContainsDiagnosticSourceAssembly, and AppContainsAspNetTelemetryCorrelationAssembly.

If any of these entries exist, remove the following packages from your application: Microsoft.ApplicationInsights, System.Diagnostics.DiagnosticSource, and Microsoft.AspNet.TelemetryCorrelation.

参考资料

Application Insights 简介 : https://learn.microsoft.com/zh-cn/azure/azure-monitor/app/app-insights-overview?tabs=webapps

Troubleshoot Application Insights integration with Azure App Service : https://learn.microsoft.com/en-us/troubleshoot/azure/azure-monitor/app-insights/telemetry/troubleshoot-app-service-issues?tabs=net%2Cnet-1%2Cnet-2%2Cpython-3

排查 Azure 应用程序 Insights 代理问题 : https://learn.microsoft.com/zh-cn/troubleshoot/azure/azure-monitor/app-insights/agent/status-monitor-v2-troubleshoot#iis-classic-pipeline-mode


当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

相关推荐
vx_Biye_Design4 分钟前
springboot旅游管理系统18006-计算机课程设计、毕业设计
java·spring boot·后端·python·elasticsearch·django·课程设计
半亩码田11 分钟前
C#转Python第4.7篇:logging:Python 的标准日志库
开发语言·python·c#
QUDONG_biubiubiu21 分钟前
.NET Runtime 6.0/7.0/8.0/9.0下载修复教程,软件打不开这样解决
.net·net runtime下载·net运行库修复·net runtime安装
外收内放33 分钟前
Python基础语法练习题(59-原始版本与优化版本)
开发语言·python
ASS-ASH36 分钟前
从力学与机械原理角度深度剖析:尊界V800刹车踏板支架断裂事件的技术逻辑
人工智能·python·数据可视化·机械工程·汽车安全·物理仿真·制动系统
xhy_070737 分钟前
AI 读了 .env,密钥会原样发给大模型吗?WES Code 的密钥打码(附实测)
人工智能·python·数据挖掘·flask·ai编程·wes code
宝桥南山42 分钟前
.NET 11 - 尝试创建一下AGUIServer和AGUIClient(基于新版.NET SDK for AG-UI)
microsoft·ai·微软·c#·aigc·.net
泡海椒44 分钟前
JQuick-Excel 实战:用 STYLE 配置单元格与区域样式
开发语言·python·excel
威联通网络存储1 小时前
TS-h1283XU-RP 在医药批记录与检验场景的部署
网络·python
波力海苔夹心脆6751 小时前
C# LINQ 入门到上手:一篇讲透查询语法、常用操作符与延迟执行(含示例与速查表
经验分享·c#·.net·solr·linq