azurecronazure-functionscron-taskcrontrigger

How to set cron expression for multiple time periods


I have a requirement to trigger cron job at 9 am and 10.15 pm every day. i.e the trigger will be as:

next today at 09:00:00
then today at 22:00:00
then today at 22:15:00
then next day at 09:00:00 and so on...

I have done it as * 0,15 9,22 * * * but it will also get triggered at 9.15 am which I don't want. Please help me with creating this expression.

If this is not possible can anyone please suggest how to write multiple cron expressions in time triggered azure function. Here is my code:

[FunctionName("Function1")]
public void Run([TimerTrigger("* 0,15 9,22 * * *")] TimerInfo myTimer, ILogger log)
 {
  //my code here
 }

Solution

  • As far as I know, you can't create such a CRON expression in a Function, I can think of what you need to create two functions. A function CRON Expression: * 0 9,22 * *, another CRON expression: * 15 22 * *.