Search code examples
azurecronazure-functions

Azure Functions Timer Trigger thread safety


I was wondering if anybody knows what happens if you have a Cron setting on an Azure Function to run every 5 minutes if its task takes more than 5 minutes to execute. Does it back up? Or should I implement a locking feature that would prevent something, say in a loop, from handling data already being processed by a prior call?


Solution

  • Azure function with timer trigger will only run one job at a time. If a job takes longer then next one is delayed.

    Quoting from 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.

    That is true even if you scale out.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-timer#scale-out

    You may want to ensure that your function does not time out on you. See https://buildazure.com/2017/08/17/azure-functions-extend-execution-timeout-past-5-minutes/ on how to configure function timeout.