Scheduling with Azure Functions
  • Updated on 18 Apr 2019
  • 1 minute to read
  • Contributors
  • Print
  • Comments
  • Share
  • Dark
    Light

Scheduling with Azure Functions

  • Print
  • Comments
  • Share
  • Dark
    Light

#ServerlessTips - Azure Functions
Author: Steef-Jan Wiggers Azure MVP

Like Logic Apps you can schedule Functions to perform recurring tasks and flows (durable function). One of the triggers for Azure Functions is the timer-trigger – allowing you to run a function on a schedule. With the timer trigger, you can use cron-expression to define when the function needs to run.

A cron expression has six fields:
{second} {minute} {hour} {day} {month} {day-of-week}

The cron expressions you can use are listed in the table below.

Value Allowed Expressions Description
{second} 0-59; * {second} when the trigger will be fired
{minute} 0-59; * {minute} when the trigger will be fired
{hour} 0-23; * {hour} when the trigger will be fired
{day} 1-31; * {day} when the trigger will be fired
{month} 1-12; * {month} when the trigger will be fired
{day of the week} 0-6; MON-SUN; * {day of the week} when the trigger will be fired

An example of a cron-expression is as follows:

public static void Run([TimerTrigger("0 */5 * * * * ")] TimerInfo myTimer, ILogger log)

The trigger in the code sample above will run every five minutes.

You can find many cron-expression samples online and that the timezone by default is set to Coordinated Universal Time (UTC). In case you need another time zone you will need to create an app setting for your function app named WEBSITE_TIME_ZONE – specify the value to the name of the desired time zone (see Microsoft Time Zone Index).

For more information about cron-expressions watch this Middleware Friday episode:

Was this article helpful?