Azure Data Factory triggers: schedule, tumbling, event

The trigger types in Azure Data Factory, what each one is for, and why a tumbling window trigger suits loads that must cover every hour exactly once.

Short answer: a trigger starts a pipeline run. A schedule trigger runs on a clock, a tumbling window trigger runs once for each fixed time window (and can run past windows again), a storage event trigger runs when a file arrives or is deleted, and a custom event trigger runs on an Event Grid event you publish.

Most pipelines start on a schedule trigger and that is fine. The others solve two specific problems: covering every time window exactly once, and starting as soon as a file lands instead of polling for it.

Which trigger does what?

TriggerStarts a runGood for
Scheduleat clock times, like 02:00 dailymost nightly loads
Tumbling windowonce per fixed window, back to a start dateloads per hour or day, with backfill
Storage eventwhen a blob is created or deletedfiles dropped by another system
Custom eventon an Event Grid event you publishother systems saying "ready"
Four triggers in Azure Data Factory

Why use a tumbling window?

  1. 1
    08:00 to 09:00succeeded
  2. 2
    09:00 to 10:00failed, retried by the trigger
  3. 3
    10:00 to 11:00waits for 09:00 if it depends on it
  4. 4
    11:00 to 12:00runs when its hour is over
Every hour once, even after an outage

A tumbling window trigger hands the pipeline the window it covers, so the copy reads exactly those rows:

SELECT * FROM dbo.Orders
WHERE ModifiedDate >= '@{trigger().outputs.windowStartTime}'
  AND ModifiedDate <  '@{trigger().outputs.windowEndTime}'

Set its start date in the past and it runs every window since then: a backfill with no extra pipeline. It can also wait for another tumbling window trigger, retry a failed window on its own, and limit how many windows run at once.

A schedule trigger knows none of this. If the 02:00 run fails, nothing reruns it, and the pipeline must work out for itself which rows to load; a watermark does that.

When does a storage event trigger help?

When another system drops files at unpredictable times. The trigger fires on Blob created for a path you filter (for example, /landing/blobs/orders/ ending in .csv) and passes the file to the pipeline in @triggerBody().fileName and @triggerBody().folderPath. It uses Azure Event Grid, so the subscription needs the Microsoft.EventGrid resource provider registered.

What goes wrong?

  • A storage trigger fires before the file is complete. Have the sender write to a temporary name and rename it when done, and filter on the final extension.
  • Time zones. Schedule triggers take a time zone; tumbling windows run in UTC. Make sure "yesterday" means the same day in both.
  • The trigger is not started. A trigger published but not started does nothing. Triggers are also stopped during a CI/CD release and need starting again.

Where can you check this?

Where do you start?

Load only the rows that changed, with a watermark is the pattern for a schedule trigger, and Release Data Factory pipelines like code stops and starts the triggers around a release.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.