5
votes

In my dev environment, I have an Azure Functions with 21 functions and the app plan is consumption.

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. Great.

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 * * *"
}

Generally, speaking, this approach was working in dev environment and it is working perfectly in the production environment.

Because each function sends an email, I expect each morning to find in my inbox some emails but it doesn't happen. Then, I open the Azure portal to see the logs and the monitor.

Open the Azure function in the portal.

enter image description here

Open the monitor for a function

enter image description here

Voila, after a couple of seconds, I start to receive the email for all services! In the production environment I don't have all the function I have in dev because I want to test before deploying. In prod the functions are working fine and start at the right time.

If I look at Application Insights, I can find only the logs for the time I opened the monitor.

enter image description here

There is one interesting thing in the log:

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

enter image description here

Update

Apparently, you can't have more than a couple of timer triggers in the same Azure Functions. I opened an issue on Github, so if other devs are facing the same. Something similar with HTTP triggers, look this post.

1
Please provide how you setup the timer trigger - most probably in in host.json as well as the Function App invocation logs showing that the function runtime is not working as expected. A working timer trigger results in a log message like Executing 'Functions.TimerTrigger' (Reason='Timer fired at 2020-07-24T06:00:00.0187114+00:00', Id=b02d2633-c3a4-4050-88ce-c6f8abfb8ed7)Sascha Gottfried
Could you please provide more details of your time trigger function such as when did you set the second function be triggered and when did you open the portal monitor page(The actual execution time of the function).Frank Gong
There are too many functions in your function app, they may interact each other. I met similar problem with this, in that case, the timer trigger functions in one function app and did not work. But when i deploy them to different function apps, they work fine. so could you please deploy your second function to another function app?Frank Gong
@FrankGong you are right. I split the function and there are working. It is so annoying! Look my another post stackoverflow.com/questions/63115975/…Enrico
I opened an issue on Github, so if other devs have the same problem github.com/Azure/Azure-Functions/issues/1666Enrico

1 Answers

1
votes

There are too many functions in your function app, they may interact each other. I met similar problem with this, in that case, the timer trigger functions in one function app and did not work. But when i deploy them to different function apps, they work fine. so you can try to deploy your second function to another function app.

And I suggest you report this problem to Microsoft, they can know more information about this problem, and may have a better solution.