1

I want to execute Azure timer trigger with the sequential execution.

Suppose i have C# Timer trigger with 5min interval. But function takes time to execute is 8min. that means before completion of first call second trigger starts another thread. how can i avoid this?

Avinash patil
  • 1,689
  • 4
  • 17
  • 39

2 Answers2

8

The defaut behavior is that at any given moment only one instance of your Azure function will be running. Quoting from the wiki -

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.

Here is the log output of test function that is scheduled to run every 30 seconds but takes 40 seconds itself to execute.

C# Timer trigger function triggered at: 8/4/2017 2:21:50 PM. C# Timer trigger function executed at: 8/4/2017 2:22:30 PM. Execution count 1

C# Timer trigger function triggered at: 8/4/2017 2:22:30 PM. C# Timer trigger function executed at: 8/4/2017 2:23:10 PM. Execution count 2

C# Timer trigger function triggered at: 8/4/2017 2:23:10 PM. C# Timer trigger function executed at: 8/4/2017 2:23:50 PM. Execution count 3

alwayslearning
  • 4,493
  • 6
  • 35
  • 47
1

You can set up time-triggered function to put a message into the queue and have another function (queue-triggered) run the processing for every message in the queue. It is possible to limit number of messages fetched from the queue, check here: Throttling Azure Storage Queue processing in Azure Function App However, triggering 8-minute processing every 5 minutes sounds like a serious problem. Think it over thoroughly if it's the average processing time.

wojtekdo
  • 374
  • 1
  • 8