Does each azure instance run cron? Does each azure instance run cron? asp.net asp.net

Does each azure instance run cron?


So far I've found 3 ways to do cron jobs BUT they all require some level of managing the multiple instances possibly running the tasks.

The choices I've used so far:

  1. Windows Task Scheduler - create a startup script that adds the user and task the schedules it. More information here: Running Azure startup tasks as a real user and here: Building a Task Scheduler in Windows Azure

  2. Using Quartz.Net - this I started with, but then moved to the windows task scheduler, but it may work for you since you can customize stuff easier. More information here: Using Quartz.net to Schedule Jobs in Windows.Azure Worker Roles

  3. Using the new job scheduler in Mobile Services. I have not used this one, but when I read this blog: Job Scheduling in Windows Azure late last year I put it on my mental list to look at next time I need a job scheduler. It's still a little new, but it also may help you.


In your example, all 4 instances will try and run the cron job. If you would want to have only one instance run the job, you would need to implement some kind of "locking" mechanism. What normally folks do is that each instance will try and acquire a 1 minute lease on the same blob. Only one instance will be successful in acquiring the lease. You can put the logic that only the instance which is able to acquire the lease is executing that cron job.


As other users said, there are many ways to do that. I add a couple of suggestions. Have you developed a Cloude service web role or a Web site. If the former, the easiest way is to create also 1 worker role (only one) and run tasks from there. It the latter, you need an external "trigger": you can use Scheduler (by Aditi). You can get it from the Azure store (there is a free flan).