RPM1984
RPM1984

Reputation: 73102

Azure Functions Timer Trigger Scale-out

If i have an Azure Function which runs on a timer trigger every 5 minutes, what happens if one run takes more than 5 minutes?

Will the next timer trigger kick off, regardless of any currently executing triggers?

Reason i ask: I need to ensure only 1 Azure Function is running at a time (yes, i know this kind of goes against the concept of functions). If one run takes < 5 minutes (most of the time it should), great - kick off next one at the next 5 minute window. If it doesn't finish, don't kick off.

I'd prefer to use Azure Functions, but in this case - should i just not bother and simply use a continuously running Azure WebJob instead?

Thanks!

Upvotes: 5

Views: 2558

Answers (2)

Eduardo Russo
Eduardo Russo

Reputation: 4219

On a timer trigger, you have the option to set an "TimeSpan" instead of an "NCRONTAB" timer.

This interval starts counting right after the execution finished and is set like this:

{
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "00:01:00"
    }
  ]
}

More information on MS' documentation.

Upvotes: 0

mathewc
mathewc

Reputation: 13558

As described in the TimerTrigger wiki page:

If your function execution takes longer than the timer interval, another execution won't be triggered until after the current invocation completes. The next execution is scheduled after the current execution completes.

So you should be getting the behavior you're looking for already - only a single function invocation running at any given time.

Upvotes: 8

Related Questions