ThomasArdal
ThomasArdal

Reputation: 5259

TimerTrigger doesn't always fire in Azure Functions

I'm experiencing TimerTrigger not actually triggering in multiple of my Azure Functions. The flow always looks similar to this:

Timers

As shown in the log statements, this timer is configured to trigger every 5 minutes (0 */5 * * * *). It triggers 5:10, 5:15, ... 5:40. But then on 5:45 no trigger. The same goes for 5:50. Then at 5:51 it "wakes up". I have RunOnStartup = true on my trigger, so this is probably caused by the function app being started.

My function app is consumption based, why I would expect the app to simply run on another machine if the current machine is shot down or in other ways unavailable. The app is running on Azure Functions version 3.

Am I missing something here, or does anyone experience similar issues?

Upvotes: 1

Views: 1632

Answers (1)

AjayKumarGhose
AjayKumarGhose

Reputation: 4923

AFAIK, There is no specific reason for the timer trigger not firing properly within the given time.

Few of the workaround we can follow,

I have not faced the similar issue yet, would suggest you to please try to restart/refresh your function app. or, It may be due to of the sync issue with the function which is not happening properly.

As suggested by @Anand Sowmithiran the SO THREAD, @MayankBargali-MSFT suggest about singleton lock i,e;

TimerTrigger uses the Singleton feature of the WebJobs SDK to ensure that only a single instance of your triggered function is running at any given time. When the JobHost starts up, for each of your TimerTrigger functions a blob lease (the Singleton Lock) is taken. This distributed lock ensures that only a single instance of your scheduled function is running at any time. If the blob for that function is not currently leased, the function will acquire the lease and start running on schedule immediately. If the blob lease cannot be acquired, it generally means that another instance of that function is running, so the function is not started in the current host.

Also please try to set runonstartup to false to check whether its behaving the same or not as provided the MS DOC in comment.

For more information Please refer the below links :-

Upvotes: 0

Related Questions