Search code examples
c#azure-webjobstimer-trigger

Can 2 functions be defined in one WebJob?


In one WebJob I launched 2 functions:one is a ServiceBusTrigger one and the other is a TimerTrigger one. Can the 2 function both work? Seems the ServiceBusTrigger works and TimerTrigger one does not. The TimerTrigger one is defined as

public void CheckExpiration([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer)

So it should run every 5 minutes? I log the trace when the function get called yet I do not find the expected trace.


Solution

  • Please make sure you have added config.UseTimers() in your program.cs. If you want to use TimeTrigger in webjobs, you need to add this code. The reference of this code is in Microsoft.Azure.WebJobs.Extensions nuget package. I have tested two Functions in webjob. Every thing works fine. The TimeTrigger is triggered every 1 minute automatically.

    enter image description here