Reputation: 369
We have a Cloud Services project and have a worker role set up. In our worker role we perform tasks at particular times and also put messages on the Service Queue at particular times.
The issues comes up if we have multiple worker roles up and running, messages get scheduled multiple time and we have to set up blocking to make sure only one worker role is performing the task at a time.
Instead, What I wanted to do is use either Azure WebJobs or Azure Functions. And have the Azure WebJob/Functions schedule the message and the worker role can read the message at a particular time and execute it.
Wanted to know what is the best practice for this scenario, how can I leverage either Azure Webjobs or Function to do this? Are there any example or resources that I can look at, because the resources Microsoft provides aren't very clear.
Upvotes: 4
Views: 550
Reputation: 265
If I understand correctly your scenario is: 1. A job wakes up at a certain time and puts a bunch of messages on a queue 2. Messages are picked up and processed from the queue 3 . The problem you ran into was that the scheduler ran more than once when you had multiple worker roles. If that is the case than it would be trivial to setup an Azure Function that runs on a scheduler, puts messages on a queue and then have another Azure Function pick up the messages. If you use Azure Functions dynamic hosting plans you will get auto scaling for your queue listener Function. The Azure Functions UX inside Azure management portal has templates for this scenario and you can use either C# or node.js
Upvotes: 5