我在多个 Azure 函数应用程序中看到主机定期停止并自动重新启动。 一周以来,我的 Azure 函数应用程序停止运行,但我需要手动重新启动主机。
在 ApplicationInsights 中运行以下查询:
traces
| where message == "Job host stopped" or message == "Job host started"
| order by timestamp asc
- 2022 年 1 月 23 日 20:08:42.436 作业主机已启动
- 2022 年 1 月 23 日 20:09:25.668 作业主机已停止
- 2022 年 1 月 23 日 21:08:48.800 作业主机已启动
- 2022 年 1 月 23 日 21:11:33.702 作业主机已停止
- 2022 年 1 月 23 日 22:17:03.286 作业主机已停止
- 2022 年 1 月 23 日 22:18:39.002 作业主机已启动
- 2022 年 1 月 23 日 23:10:31.580 作业主机已停止
- 2022 年 1 月 24 日 06:41:48.024 作业主机已启动
- 2022 年 1 月 24 日 06:42:44.680 作业主机已停止
- 2022 年 1 月 24 日 06:43:00.902 作业主机已启动
- 2022 年 1 月 24 日 07:10:52.220 作业主机已停止
2022 年 1 月 24 日 06:41 开始是由于手动重启我的函数应用。在此停止期间没有执行任何时间触发器。这种情况每天都会发生不止一次。没有模式。
有什么想法吗?事件日志没有用,在自动停止和手动重启之间没有日志记录。
如何解决这个问题?为什么该功能如此频繁地重新启动?
更新:手动触发器 (http) 正在重新启动主机。
最佳答案
早上好,约翰。
如果您的主机永久停止:
try checking app_offline.html file within your project.
for more detailed info: https://www.codit.eu/blog/why-is-my-azure-function-host-permanently-stopped/
如果您的问题与主机连续启动和停止有关:
这种行为可能与您的计划有关,我认为您的Azure功能中有一个消费计划。
Consumption plan: On the Consumption plan, instances of the Functions host are dynamically added and removed based on the number of incoming events.
Premium plan: Your function apps run continuously, or nearly continuously.
Dedicated plan: Run your functions within an App Service plan at regular App Service plan rates.
For more info you can go to https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale
关于Azure 函数主机自动停止且不重新启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70830504/