1
votes

In my Azure Functions I have 26 functions and only 7 with the timer trigger (see my previous post also I saw this other post but it is quite old). There is no recommendation for Microsoft about it. Some functions have a timer trigger and at the end of the process each function sends an email. I have 2 type of timer trigger:

  • run a function every 20 minutes
  • run a function once at a particular time in the night
  • Every 20 minutes the function is doing what I expect

The problem I'm facing is with the function that they have to start at a particular time. Basically, they don't start until I open the portal and do something on the Azure Function (for example open the monitor for one of them).

In the code point of view, all functions with the timer trigger are defined like that:

[FunctionName("invoiceMonthlyGeneratorTimer")]
public void Run([TimerTrigger("%Timers:GenerateMonthlyInvoices%")] TimerInfo myTimer)
{
    // ..
}

[FunctionName("invoiceDunningTimer")]
public async Task Run([TimerTrigger("%Timers:DunningTimer%")] TimerInfo timer)
{
    // ...
}

The configuration of the timer is in the settings file like:

"Timers": {
    "DunningTimer": "0 0 4 * * *",
    "GenerateMonthlyInvoices": "0 0 4 * * *"
}

Suprised that I didn't receive any email in the morning, I checked Application Insights and didn't find any logs related to the timer fuctions.

Then, I opened in the portal the Azure Functions, clicked on one function and magically, I received the email. In the logs I found same logs like the following:

Trigger Details: UnscheduledInvocationReason: IsPastDue, OriginalSchedule: 2020-07-24T05:00:00.0000000+00:00

enter image description here

As a lad suggests in the comment of my previous post, timer trigger functions are going to have a conflict and don't start. It seems quite annoying. I also opened an issue on Github.

Is there any kind of guidelines for timer trigger functions in Azure Functions? Has someone else faced the same issue as me?

2

2 Answers

2
votes

For this problem, I think it may caused by multiple functions in one function app as your previous post mentioned. I met a similar problem with http trigger function and timer trigger function in one function app. The code is very simple(I confirm that there are no errors in the code), but the timer trigger function can't be triggered on time.

Here is the post of the similar problem I met. The workaround is create the functions in different function apps. For your problem, I think you can just create the functions in different function apps as I mentioned above or you can raise a support ticket on azure portal by following the steps on this page. The azure support team will help you on it, because they can view more log details of your function. I think it's hard to get the help you want on stack overflow community.

1
votes

If it's in an App Service Plan, you need to make sure that Always On is enabled. It is enabled by default on Function Apps, but it's good to double check.

In Consumption mode, there is no such thing as Always On. Instead, your Function App should be automatically woken up when a timer is due. For this to work, your triggers need to be 'synced'.

Please refer this article for further details on troubleshooting your timer triggered function app.