azure - 计划的 Azure Web 作业超时
问题描述
我试图让 Azure webjob 每小时运行一次,但是文档非常混乱,或者我遗漏了一些东西。我正在使用TimerTrigger
具有以下签名的 a:
public void RunHourly([TimerTrigger("0 * * * *")] TimerInfo myTimer)
并将其部署在 Azure 中。当我在 Azure 中运行 webjob 时,在输出中我看到:
[06/24/2021 11:35:32 > 886219: INFO] info: Host.Triggers.Timer[5]
[06/24/2021 11:35:32 > 886219: INFO] The next 5 occurrences of the 'RunHourly' schedule (Cron: '0 * * * *') will be:
[06/24/2021 11:35:32 > 886219: INFO] 06/24/2021 12:00:00Z
[06/24/2021 11:35:32 > 886219: INFO] 06/24/2021 13:00:00Z
[06/24/2021 11:35:32 > 886219: INFO] 06/24/2021 14:00:00Z
[06/24/2021 11:35:32 > 886219: INFO] 06/24/2021 15:00:00Z
[06/24/2021 11:35:32 > 886219: INFO] 06/24/2021 16:00:00Z
所以一切看起来都很好。在 azure 门户的 webjob 窗格中,计划列的值为 n/a,因为我没有在 settings.job 中提供计划,当我手动启动 webjob 时,几分钟后出现以下错误
[06/24/2021 11:41:34 > 886219: ERR ] Command 'cmd /c ""run.exe""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
cmd /c ""run.exe""
[06/24/2021 11:41:35 > 886219: SYS INFO] Status changed to Failed
[06/24/2021 11:41:35 > 886219: SYS ERR ] System.AggregateException: One or more errors occurred. ---> Kudu.Core.Infrastructure.CommandLineException: Command 'cmd /c ""run.exe""' was aborted due to no output nor CPU activity for 121 seconds. You can increase the SCM_COMMAND_IDLE_TIMEOUT app setting (or WEBJOBS_IDLE_TIMEOUT if this is a WebJob) if needed.
所以我的问题是我应该如何使用 TimerTrigger 让一个方法每小时或每天运行一次?我是否也需要有一个时间表(有点违背 TimerTrigger 的目的)?
任何帮助表示赞赏
解决方案
对于每小时运行一个方法的要求,您可以使用 azure 函数 timertrigger 而不是 webjob。
您可以参考此文档了解如何创建函数应用,然后在函数应用中创建计时器触发器。指定定时器触发器的 cron 表达式时,请用0 0 * * * *
. 然后每隔一小时触发一次。
推荐阅读
- javascript - jQuery UI 自动完成不会更新 ngModel
- c++ - 为什么计算每个矩阵列比使用矩阵乘积更快?
- react-native - 如何使用 react-native-router 将数据从一个屏幕传递到另一个屏幕
- c# - 在不同的集合中按顺序运行测试
- python - TypeError:字符串索引必须是整数..有什么问题
- asp.net - ASP.NET MVC5 - 返回部分视图后不执行 RenderPartial()
- algorithm - 如何计算这个细胞的概率是我的
- oracle - Oracle Schema 下每个表的行数和大小
- javascript - 如果未启用原理图,如何将节点模块添加到 Angular 项目?
- http-live-streaming - medialement.js 不适用于我在 iPhone 上的 hls