我在 azure 中有一个 Web 作业,我尝试使用 Cron 作业表达式每 2 小时运行一次。我已将作业配置为 OnDemand
,并且我相信我已正确设置 Cron 表达式。然而,它永远不会被启动。已经出来2天了。
以下是这项工作的快速概述:
Program.cs
namespace ScheduledTrigger
{
class Program
{
static void Main()
{
var config = new JobHostConfiguration();
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
var host = new JobHost(config);
host.Call(typeof(Functions).GetMethod("ManualTrigger"), new { value = 20 });
}
}
}
函数.cs
[NoAutomaticTrigger]
public static void ManualTrigger()
{
var model = new ScheduledTriggerModel();
///more stuff here...
}
webjob-publish-settings.json
{
"$schema": "http://schemastore.org/schemas/json/webjob-publish-settings.json",
"webJobName": "ScheduledTrigger",
"runMode": "OnDemand"
}
设置.作业
{ "schedule": "0 2,4,6,8,10,12,14,16,18,20,22 * * *" }
我也尝试过这个:
设置.作业
{ "schedule": "0 */2 * * *" }
这是我在 Azure 中的工作的屏幕截图。正如您所看到的,我以相同的方式设置了其他作业(使用不同的 Cron 表达式),并且运行得很好。其他作业设置为每天运行,而此作业每天运行多次。
我在这里缺少什么吗? Azure 是否不允许作业每天运行多次(它们现在有内置的调度程序,但价格昂贵)?
最佳答案
关于c# - Cron 表达式在 Azure 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51987079/