我试图让 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 的目的)?
任何帮助表示赞赏