【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


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

相关推荐
AneiangSoft3 小时前
Aneiang.Yarp v2.3.0.25:让 AI 成为你的 API 网关运维副驾驶
网关·.net·代理·dashboard·yarp
yaoxin5211234 小时前
462. Java 反射 - 获取声明类与封闭类
java·开发语言·python
中微极客5 小时前
解锁LLM开发全栈能力:Python + LangChain + RAG 工程实战指南
人工智能·python·langchain
hhzz5 小时前
Barbershop:基于GAN和分割Mask的图像合成技术——从理论到实战全解析
图像处理·人工智能·python·深度学习·计算机视觉
Ulyanov6 小时前
雷达导引头Python仿真框架:GPU加速、6-DOF模型与半实物仿真接口
开发语言·python·雷达信号处理·雷达导引头
列逍7 小时前
博客系统测试
自动化测试·python·性能测试
星云开发8 小时前
拒绝无效加班!用Python打造自动化办公流,附Word/PDF互转硬核代码
python
dream_home84078 小时前
图像算法模型NPU适配与算法服务实战指南
人工智能·python·算法·npu 图像服务
AIGS0018 小时前
跨越语义鸿沟:企业本体语义平台的构建与落地
java·人工智能·python·机器学习·人工智能ai大模型应用
李可以量化8 小时前
PTrade 量化策略实战:二八轮动策略深度解析(下)
python