gpt4 book ai didi

c# - CRON 表达式在每月的最后一天触发 Azure 函数

转载 作者:行者123 更新时间:2023-12-03 00:20:31 25 4
gpt4 key购买 nike

是否有任何 CRON 表达式可以用来在每个月的最后一天触发 Azure 函数?这似乎是定时器触发器的典型场景,我很惊讶我正在努力弄清楚这一点。

我目前正在使用一种解决方法,即在每月的 28-31 日触发并检查代码(如果是该月的最后一天),但该解决方案感觉有点老套。

即使是明确的“不可能”也会受到赞赏。

编辑:这是代码

using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using System;

namespace MyProsj.Functions.Triggers
{
public static class LastOfEachMonth
{
[FunctionName("LastOfEachMonth")]
public static void Run([TimerTrigger("0 0 20 28-31 * *")] TimerInfo myTimer, ILogger log)
{
if (DateTime.Now.AddDays(1).Day == 1)
{
//DO STUFF HERE
}
}
}
}

最佳答案

这是用于在每月最后一天运行 Azure 函数触发器的 Corn 表达式。上午 10:15

15 10 * * 5L

enter image description here

有关更多信息,请查看此 Corn Expressions .

关于c# - CRON 表达式在每月的最后一天触发 Azure 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70004217/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com