Azure webjob; Scheduled execution, as well as triggers in turn

I am trying to figure out if it is possible to make one Azure website and behave so that it speaks once in 1 minute, and also allows it to run in the queue. I managed to fulfill both requirements separately, but not combined into one work.

I know that in order to get them to run in the queue, I need to use the JobHost and Function class, using methods that capture the trigger. However, this blocks the scheduler and only processes triggers.

When I omit JobHost ... well, then the graph works fine. I am almost sure that I ask for contradictions and just need to do two separate tasks, but perhaps one of you has faced the same and managed to achieve this.

+5
source share
1 answer

I would not use Azure Scheduler / Scheduled Jobs here, since you are already using the SDK. You can use the new TimerTrigger .

What I will probably do consists of two functions. The first function is a function using QueueTrigger , while the other uses the new TimerTrigger WebJobs released in version 1.1. You can see a sample where I am doing something similar here: https://github.com/christopheranderson/feedbackengine#how-does-it-work

There I have a timer that polls the RSS feed and discards queue messages, but I can also just drop the queue messages from another application or, as it was in my scenario, use WebHook.

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

Example:

 // 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); } 
+4
source

Source: https://habr.com/ru/post/1237366/


All Articles