Azure webjob; Scheduled execution as well triggers by queue

天大地大妈咪最大 提交于 2019-12-01 17:38:24

I wouldn't use Azure Scheduler/Scheduled Jobs here, since you're already using the SDK. You can use the new TimerTrigger.

What I'd probably do is have two functions. The first function is the function using QueueTrigger and the other is using the new TimerTrigger WebJobs released in v1.1.0. You can see a sample where I do something similar here: https://github.com/christopheranderson/feedbackengine#how-does-it-work

There I have a timer which polls an RSS feed and drops Queue messages, but I can also just drop the Queue messages from another application or, as I did in my scenario, use a WebHook.

Timer Trigger Docs: https://github.com/Azure/azure-webjobs-sdk-extensions#timertrigger

Sample:

// Triggers every minute (every time the clock looks like 00:xx:xx)
public static void CronJob([TimerTrigger("0 * * * * *")] TimerInfo timer, [Queue("Foo")] out string message)
{
    Console.WriteLine("Cron job fired!");
    message = "Hello world!";
}

public static void QueueJob([QueueTrigger("Foo")] string message)
{
    Console.WriteLine(message);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!