【Azure App Service】分享App Service for Window中自动抓取Memory DUMP的方法

问题描述

当应用部署到Azure App Service后,如果突然遇见应用内存上升的情况,如果想 第一时间的抓取Memory DUMP,以便于分析出内存占用到上限值的根源,有什么好的办法呢?

 

问题解答

如果是 Windows App Service,最简单的做法是开启 Auto-Heal:触发条件选内存上限,动作选 Collect a Memory Dump。进程私有内存超过阈值时,系统会自动抓 dump。

Auto-Heal provides you with an easy way to take an action when your app is having an unexpected behavior. The triggers and actions allow you to define various conditions based on request count, slow requests, memory limit on which you can take specific actions like restarting the process, logging an event, or starting another executable. Please note that these mitigations should only be considered a temporary workaround until you find the real cause for the issue causing the unexpected behavior.
具体的操作步骤如下:
  1. 打开 Azure Portal,进入目标 Web App。
  2. 依次点 Network  → Troubleshoot → Auto-Heal。
  3. 打开 Custom Auto-Heal Rules(自定义自动修复规则)。
  4. Conditions(触发条件):选 Memory Limit,填内存阈值。这个值指的是单个实例上 w3wp 进程的 Private Bytes。
  5. Actions(动作):选 Custom Action → Collect a Memory Dump。
    • 可以选抓完 dump 后是否同时分析,或是否重启进程(Kill)。
    • 如果门户提示配置存储账户,就按提示绑定一个。dump 会写到那个存储账户里。
  6. Override when action executes(最短运行时间):建议设成 5–10 分钟,防止进程刚启动就反复触发。
  7. 点 Save。保存后站点会重启一次,规则才会生效。

操作步骤截图参考:

image

 

参考资料

Auto Healing Experience in App Service Diagnostics :https://azure.github.io/AppService/2018/09/10/Announcing-the-New-Auto-Healing-Experience-in-App-Service-Diagnostics.html

 

posted @ 2026-10-15 21:32  编码者卢布  阅读(3)  评论(0)    收藏  举报