Reputation: 211
I want to do very basic cron job on Azure Function. I'm writing functions on Visual Studio and the functions will be dockerized job. There are two different azure function on my solution.
My expectation is that the functions shouldn't block eachother. So, they shouldn't work at the same time. My cron expressions for the functions are;
I don't want to run function2 on every month like 01/01/2021 00:00:00. How can I exclude the time from function2?
Upvotes: 0
Views: 416
Reputation: 29940
There is no direct way to do that.
As a workaround, you can add if else
code block in Function2. For example, in the if block
, you can determine if it's the time like 01/01/2021 00:00:00
. if yes, then do nothing. If not, then go to the else block
to execute your logic.
Like below:
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
{
var the_time = DateTime.Now;
//if the date is the first day of a month, and time is 00:00:00
if(the_time.Day==1 && the_time.ToLongTimeString().Contains("00:00:00"))
{
//do nothing, don't write any code here.
}
else
{
//write your code logic here
}
}
Upvotes: 1