我是 azure web 作业的新手。我正在使用版本 2.0.0 的 azure 扩展和核心。我正在使用 this git repo据我所知,它使用了 nigets 的 beta 版本。目前我正在本地机器上以 Debug模式运行应用程序。我创建了一个函数,使用 TimerTrigger 每分钟运行一次。代码如下,
static void Main()
{
var config = new JobHostConfiguration();
config.UseTimers();
config.Tracing.ConsoleLevel = System.Diagnostics.TraceLevel.Verbose;
if (config.IsDevelopment)
{
config.UseDevelopmentSettings();
}
var host = new JobHost();
// The following code ensures that the WebJob will be running continuously
host.RunAndBlock();
}
[NoAutomaticTrigger]
public static void TimerTrig([TimerTrigger("0 * * * * *", RunOnStartup = true)] TimerInfo timer)
{
Console.WriteLine("Triggered");
}
我的问题是, - 我在网上看到的示例都没有使用 [NoAutomaticTrigger] 属性。但如果我不使用它,作业主机将无法找到该功能本身。 - 该功能未触发。我在 cron 符号中使用了设置时间,run start up = true,使跟踪控制台级别变得冗长。
我错过了什么?
请您参考如下方法:
尝试将您的配置作为参数传递给作业主机构造函数。
var host = new JobHost(config);
