【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


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

相关推荐
兵慌码乱10 小时前
面向桌面端的资产管理系统分层架构设计与核心模块实现
python·系统架构·sqlite·pyqt5·数据库设计·桌面应用开发·mvc架构
hboot11 小时前
AI工程师第三课 - 机器学习基础
python·scikit-learn·kaggle
顾林海16 小时前
Agent入门阶段-编程基础-Python:流程控制
python·agent·ai编程
呱呱复呱呱19 小时前
Django CBV 源码解读:一个请求是怎么找到你的 get() 方法的
python·django
唐青枫19 小时前
别只会反射:C#.NET Emit 动态生成代码实战详解
c#·.net
Caco_D1 天前
一行代码抓遍全网 20 个热榜!Aneiang.Pa 4.0 发布 — 极简 .NET 爬虫库
爬虫·.net
咕白m6251 天前
.NET 环境下 Word 超链接批量提取方案
c#·.net
曲幽1 天前
刚部署的 LibreTranslate 频频翻车?我掏出了 20 年前的 StarDict 词典,用 FastAPI 搭了个本地词典翻译 API
python·fastapi·web·translate·goldendict·libretranslate·stardict·pystardict
荣码1 天前
用Streamlit给AI应用套个界面,10行代码出Web页面
java·python
兵慌码乱1 天前
基于Python+PyQt5+SQLite的药房管理系统实现:事务一致性与界面解耦全流程解析
python·sqlite·信号与槽·pyqt5·数据库设计·桌面应用开发·事务处理