1

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?

Enrico
  • 3,592
  • 6
  • 45
  • 102
  • Does this answer your question? [Why is my python timer trigger function not running at the correct time?](https://stackoverflow.com/questions/61035038/why-is-my-python-timer-trigger-function-not-running-at-the-correct-time) – Liam Jan 27 '21 at 09:08

2 Answers2

2

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.

Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • In your experience, how many functions can we have in an Azure Functions? There is no guidelines for that. I saw somewhere that Microsoft says you can have as many functions as you want – Enrico Jul 28 '20 at 08:03
  • I opened an issue on Github, so if other devs have the same problem https://github.com/Azure/Azure-Functions/issues/1666 – Enrico Jul 28 '20 at 08:09
  • @Enrico Yes, microsoft says we can have as many functions as we want in one function app. But according to some test, if we use multiple http trigger and timer trigger functions in one function app, the timer trigger may be affected and can't be triggered on time. It doesn't matter how many functions in one function app, I just mean it may cause problem if exist multiple http trigger and timer trigger in one function app. – Hury Shen Jul 28 '20 at 08:10
  • @Enrico May I know which plan did you use for your function app ? If use consumption, could you please have a try to change to a higher plan. – Hury Shen Jul 28 '20 at 08:11
  • Yes, it is the consumption plan in dev but not in prod. – Enrico Jul 28 '20 at 08:12
  • @Enrico I'm not sure if it caused by plan. In the post I provided above, I also use consumption plan and there are only two functions(one http trigger, the other timer trigger) in the function app. The code is very simple but the timer trigger still doesn't work as expected. – Hury Shen Jul 28 '20 at 08:15
  • This is quite frustrating, honestly. I think it is a bug in Azure... – Enrico Jul 28 '20 at 08:22
  • Hi @Enrico If your functions work fine after split them to different function apps, could you please mark the answer as "accepted", thanks in advance~ – Hury Shen Jul 29 '20 at 01:10
1

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.

Enrico
  • 3,592
  • 6
  • 45
  • 102
  • Enrico, does this mean "syncing triggers" did solve this issue. If yes, this issue is more of a deployment issue. I remember a "syncing triggers" log line when I deployed functions with VS Code. How did you do deployment until that SO question and what changes did you apply to "sync triggers" eventually? – Sascha Gottfried Aug 08 '20 at 13:36