5

In this document (Timer trigger for Azure Functions) the example they give executes the function every five minutes, starting with the minutes that end in 5 or 0. That's fine, but unless I'm missing something, this document does not explain the syntax of the trigger and how I can customize it.

  public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log)
  {
      ....
  }

For testing purposes on my localhost, this is really annoying to have wait until my clock time is a minute that ends in 5 or 0. I just want the function to execute immediately when run, and then again every five minutes after that. How would I modify this syntax accordingly?

Casey Crookston
  • 13,016
  • 24
  • 107
  • 193
  • 2
    Read more about CRON Expressions [here](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer#cron-expressions) – Matt.G Mar 26 '19 at 16:22
  • @Matt.G, ok yeah, I just didn't scroll down far enough in the document. However, I think I need to set 'RunOnStartup' to true. Just gotta figure out how to do that. – Casey Crookston Mar 26 '19 at 16:32

1 Answers1

7

Just pass RunOnStartup = true when using the attribute:

[TimerTrigger("0 */5 * * * *", RunOnStartup = true)]
haim770
  • 48,394
  • 7
  • 105
  • 133