0

I'm trying to have a Azure webjob run hourly, but either the documentation is very confusing or I'm missing something. I'm using a TimerTrigger with the following signature:

public void RunHourly([TimerTrigger("0 * * * *")] TimerInfo myTimer)

and deployed it in Azure. When I run the webjob in Azure, in the output I see:

[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

so everything looks fine. In the webjob pane of azure portal, the schedule column has a value of n/a since I haven't provided a schedule in settings.job and when I start the webjob manually, I get the following error after some minutes

[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.

So my question is how I'm supposed to use the TimerTrigger to have a method run every hour or every day? Do I need to have a schedule as well (kind of defeats the purpose of TimerTrigger)?

Any help is appreciated

Albert T
  • 61
  • 2

1 Answers1

0

For your requirement of have a method run every hour, you can use azure function timertrigger instead of webjob.

You can refer to this document about how to create function app and then create timer trigger in function app. When specify the cron expression of the timer trigger, please set it with 0 0 * * * *. Then it will be triggered every hour.

Hury Shen
  • 14,948
  • 1
  • 9
  • 18