Azure Functions NCRONTAB expressions
Six fields with seconds first, read by the NCrontab library. It looks like cron with one extra field, but it combines the day fields the other way round.
At 09:30, on Mondays, in January.
Next 10 runs
Clock changes
In your config
In the other dialects
“Same schedule” means the same clock times. Schedulers still treat a clock change differently, as the table on the home page shows.
Keyboard: / edit the expression, 1 to 6 change dialect, t time zone, n next clock change, c copy the link, Esc leave a field.
Fields
| Field | Values | Special characters |
|---|---|---|
| Second | 0–59 (omit for the 5-field form) | * , - / |
| Minute | 0–59 | * , - / |
| Hour | 0–23 | * , - / |
| Day | 1–31 | * , - / |
| Month | 1–12 or names | * , - / |
| Day of week | 0–6, where 0 is Sunday, or names | * , - / |
Special characters
*- All values:
0 * 5 * * *runs every minute of hour 5. -- A range:
5-7 * * * * *. NCrontab swaps a backwards range, so10-5means 5 through 10, not a wrap-around. ,- A set:
5,8,10 * * * * *. /- An interval:
0 */5 * * * *. - Names
- English and case-insensitive:
Mon,Monday,Jan. NCrontab takes the first prefix match, soJis January andJuis June. Use three letters.
The two day fields
NCrontab checks both day fields. 0 0 12 1 * Mon fires only when the 1st is a Monday, where Unix cron would fire on every 1st and every Monday. The docs do not call this out, but NCrontab’s code and its test suite do it. Useful side effect: 0 0 9 1-7 * Mon really is the first Monday of the month.
Time zones
UTC by default. Set the WEBSITE_TIME_ZONE app setting: a Windows name on Windows, a tz database name on Linux Premium or Dedicated. It is not supported on Linux Consumption or Flex Consumption, where Microsoft warns that setting it can cause SSL issues and stop metrics.
Clock changes
Microsoft says only that WEBSITE_TIME_ZONE adjusts for time changes. The details are in the CronSchedule source, which this tool ports and checks against its tests. A time in the gap moves forward by the size of the gap, so 02:30 becomes 03:30. In the repeated hour, a fixed-time schedule runs once. A schedule with *, / or - in its time fields runs through both passes.
Gotchas
- A 5-field expression gets second 0. The docs’ note says both forms are supported.
- A value of
5in the hour field means 05:00, not every 5 hours. - If an expression is invalid, the portal’s function test shows a 404. With Application Insights connected, more detail is logged there.
- Timer triggers do not retry after a failure. The function next runs at its next scheduled time.
runOnStartupalso fires on every scale-out and restart. Microsoft says not to set it in production.- A
TimeSpansuch as01:00:00only works on an App Service plan. If the first number is 24 or more, the format is days:hours:minutes, so24:00:00is 24 days. - If a function app scales out, one instance runs the timer. Function apps sharing storage can collide if they share a host ID.
Examples to try
- 0 */5 * * * *Every five minutesEvery 5 minutes
- 0 0 * * * *The top of every hourEvery hour, on the hour
- 0 0 */2 * * *Every two hoursEvery 2 hours
- 0 0 9-17 * * *Hourly from 9 AM to 5 PMOn the hour from 09:00 through 17:00
- 0 30 9 * * 1-509:30 on weekdaysAt 09:30, Monday through Friday
- 0 30 9 * Jan MonMondays in JanuaryAt 09:30, on Mondays, in January
- 0 0 12 1 * MonOnly when the 1st is a MondayAt 12:00, on the 1st of the month, but only when that day is also Monday
- 01:00:00A TimeSpan, not a calendar scheduleEvery 01:00:00, counted from when it starts