Share via

Azure function stopped running on a scheduled time

Lukasz Kurzysz 0 Reputation points
2024-03-26T07:38:29.1933333+00:00

My Azure Function runs a Python script. It queries several databases and stores the results in a blob. The function is scheduled to run almost every two hours according to the following schedule:

"schedule": "0 3,5,7,9,11,13,15,17,19 * * *"

Part of the databases only need to be queried once a day, so I included the following code in my Python script, expecting that the function running at 19:00 would execute this part of the code:

if current_time.hour >= 18 or current_time.hour < 2:

Unfortunately, the function is run several minutes after... 2am. It worked in the past. I have tried different hours in the Python script and in the schedule, but the function always runs after the hours set in the Python script.

Azure Functions
Azure Functions

An Azure service that provides an event-driven serverless compute platform.


1 answer

Sort by: Most helpful
  1. Ryan Hill 30,336 Reputation points Microsoft Employee Moderator
    2024-03-26T16:01:17.6833333+00:00

    Hi @Lukasz Kurzysz,

    I think your schedule might be off. The second value in the NCRONTAB expression should be minute. It could also be due to DST if your function is deployed to North America based region that doesn't have the time zone set.

    Having said that, I would adjust your schedule property to "0 0 */2 * * *". This will ensure your trigger is runs every two hours at the top of the hour. Furthermore, if the database call isn't too intensive, the I would just make the db call when the function is invoked to keep things simple.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.