Azure Functions with timer trigger: UnscheduledInvocationReason

Enrico Rossini 181 Reputation points
2020-07-31T15:58:47.693+00:00

In my Azure Functions I have 26 functions and only 7 with the timer trigger. 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

ZuBdX.png

Apparently, timer trigger functions have a conflict with more than 3 functions and don't start. It seems quite annoying. I also opened an issue on Github1666.

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

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,565 questions
{count} votes

1 answer

Sort by: Most helpful
  1. ChaitanyaNaykodi-MSFT 24,231 Reputation points Microsoft Employee
    2020-08-06T23:21:59.763+00:00

    Hello @Enrico Rossini ,
    Thank you for the patience! I got a response from the Product Group regarding the issue and they mentioned that every timer trigger in a function app consumes some CPU and storage to poll and understand when it can/should fire. If there are many timer triggers in the same app, the increase in CPU demands of that core may cause delays or issues. There is no set number for timer triggers in a single function app as it depends on the overall CPU demands of the app. So hence, it will be safe to split the functions in multiple function apps, just to be sure that CPU cycles do not interfere each other. You can also find some additional information here in this troubleshooting guide. I do understand that the official documentation for timer trigger on Microsoft Learn does not provide this information, if possible it will be very helpful if you could please raise a “doc-issue” on the official documents you referred for timer trigger, as this will create a work item and we will be able to follow the complete cycle for the doc update.

    Apart from this, during our discussion with Product Group we found out that there might be some app setting issue on your function app, you can refer to this issue for more information as it is similar to your scenario. Even if this does not resolve the error, I will suggest that you create a support ticket for the issue as it will require a more personalized deep dive into logs and settings. If you do not have a support plan for your Azure subscription id, you can send an email with subject line “Attn:Chaitanya” to AzCommunity[at]Microsoft[dot]com referencing this thread ,Azure subscription ID and your function app name. I will follow-up with you as soon as possible.

    0 comments No comments