Drees
Drees

Reputation: 720

Azure Function - Timer Trigger (Multiple times a day not always firing properly)

I have a function that uses the Timer trigger and my cron expression is:

0 30 4,7 * * *

I also have the WEBSITE_TIME_ZONE setup as Pacific Standard Time.

The goal is to run the function twice a day at 4:30 and 7:30 am. With this expression it sometimes works.

The time that is missing doesn't even seem to be started and I am not sure why. I can run it manually multiple times and it seems to work fine. I've tested by using an example where I am running every 10 minutes; and ran it for about 2 hrs and it worked flawlessly. Perhaps there is just an issue with running at two specific times?

Log:

enter image description here

I've read somewhere it could be a known issue with the plan type (I am using a consumption plan).

I've seen a lot of posts on this forum that this isn't a feature (running two times a day at specific times). Azure Timer Function Twice in same day

However, it does seem to work, so I wasn't sure if it has been updated or if anyone has had any luck with it.

Upvotes: 0

Views: 702

Answers (1)

Pravallika KV
Pravallika KV

Reputation: 8734

I have tested the same by creating function apps with three different plans (consumption, Premium, App Service plan).

  • Able to run the function twice a day using the expression: 0 0 13,14 * * * :

enter image description here

Consumption:

  • Tried the function twice using the CRON expression * 21 13,14 * * *(didnt change the time zones).
  • The function triggered only once.

enter image description here

  • Same happened with Premium and App Service Plans:

Premium:

enter image description here

  • App Service Plan:

enter image description here

As mentioned by @Rui Jarimba, you have to 2 different functions in the code configuring the schedule seperately like 0 30 4 * * * and 0 30 7 * * *.

  • Tested the same by creating the two functions in the same function app:
namespace FunctionApp13
{
    public class Function1
    {
        [FunctionName("Function1")]
        public void Run([TimerTrigger("0 4 16 * * *")]TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
        }
       
    }
    public class Function2
    {
        [FunctionName("Function2")]
        public void Run([TimerTrigger("0 5 16 * * *")] TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
        }

    }
}

Portal:

enter image description here

  • Could trigger the function at respective times:

Function 1:

enter image description here

Function 2:

enter image description here

Upvotes: 1

Related Questions