Oleg Sh
Oleg Sh

Reputation: 9013

Azure Function and CRON again

I want to call every day at 23:00.

I try the following:

        [TimerTrigger("0 23 * * *")]TimerInfo myTimer,

but I get an error:

Microsoft.Azure.WebJobs.Host: Error indexing method 'FunctionAppCallEfsFuelCards.Run'. Microsoft.Azure.WebJobs.Extensions: The schedule expression '0 23 * * *' was not recognized as a valid cron expression or timespan string.

what is wrong?

Upvotes: 0

Views: 1549

Answers (2)

Peter Pan
Peter Pan

Reputation: 24148

Just summarized as an answer, as @DavidMakogon said in comment, the correct crontab expression should be {second} {minute} {hour} {day} {month} {day-of-week} in Timer Trigger of Azure Functions.

The section NCRONTAB expressions of the offical document Timer trigger for Azure Functions explains it, as the figure below.

enter image description here

Upvotes: 2

Thili
Thili

Reputation: 788

The main format used for the scheduled WebJob

  • The cron expression is composed of 6 fields: {second} {minute} {hour} {day} {month} {day of the week}.
  • The supported operators are: , - * /

  • Each field can have a specific value (1), a range (1-10), a set of values (1,2,3), all values (), an interval value (/2 == 0,2,4,6,...) or a mix of these (1,5-10).

  • Each value represents a point in time, for example: "5 * * * * *" - means on the 5th second of every minutes according to above rules your cron expression will leads to this error

    use [TimerTrigger("0 0 23 * * ? *")]TimerInfo myTimer,

also you can validate your cron expression using this

Upvotes: 0

Related Questions