Azure WebJobs TimerTrigger not triggering

南楼画角 提交于 2019-12-21 17:48:44

问题


I'm trying to run WebJob as a console app, It works When I add RunOnStartup = true, but I need that it works just with TimerTrigger.

this is my code

public static void Main()
{
  JobHostConfiguration config = new JobHostConfiguration();
  config.UseTimers();
  JobHost host = new JobHost(config);
  host.RunAndBlock();
} 

public static void TimerJob([TimerTrigger("0 0 8 * * *")] TimerInfo timerInfo)
{
    Console.WriteLine("Job Work");
}

What do I need to make this code work?


回答1:


This behavior was due to an issue in TimerTrigger which has been fixed in the v1.0.1 release that is now live on Nuget.

The issue was that we were using UTC time internally when scheduling occurrences, rather than Local time as you'd expect. While this could cause confusion when running locally, your job would still run correctly on schedule in Azure.

However, this issue has been fixed now.




回答2:


First of all, add the JobHostConfiguration Tracing as described here in the Local Development section. Otherwise you won't see the Console text. If you are running locally, you can always set a breakpoint too.

Keep also in mind that the TimerTrigger uses the Web App Timezone when running on Azure or your computer Timezone when running locally. To define the Web App timezone, follow these steps.




回答3:


This might not be the answer to your specific problem but it answers the very same question. I noticed that it wont find TimerTrigger functions in the Program class. When running it i just get the

Development settings applied

No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

Job host started

After putting them in Function class it triggered just fine.



来源:https://stackoverflow.com/questions/34665763/azure-webjobs-timertrigger-not-triggering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!