Schedule Azure Function to Avoid Midnight run

Ning Zhu 131 Reputation points
2022-12-09T12:46:21.943+00:00

Hi there,

I have a question, there is job I need to run every 15 minutes, that is very easy through CRON setting.

However, there is an organizational policy to NOT run anything during 23:30 to 00:30 since system refresh.

I cannot find out how to set this configuration in CRON, no intention to rewrite codes at this point.

Any help is highly appreciated!

Thanks!

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

Accepted answer
  1. MayankBargali-MSFT 70,936 Reputation points Moderator
    2022-12-14T05:25:31.263+00:00

    @Ning Zhu Thanks for reaching out. Azure Functions uses the NCronTab library to interpret NCRONTAB expressions. NCRONTAB expression supports both five field and six field formats. The sixth field position is a value for seconds which is placed at the beginning of the expression. For more details you can refer to this document.

    You can refer to below NCrontab Expression Tester: https://ncrontab.swimburger.net/
    Alternative: https://crontab.guru/

    Unfortunately, as there is no CRON expression as per your requirement which will not execute between 23:30 to 00:30 everyday.
    The workaround will be handling this in your code. Your function will get executed every 15 minutes using the CRON 0 */5 * * * *
    Inside your function app you will have condition to check the current time and if the current time doesn't fall between 23:30 to 00:30 then execute your business logic.

    Feel free to get back to me if you have any queries or concerns.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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