Windows Azure - background/scheduled tasks?

10,534

Solution 1

The definitive (current) guide to this FAQ is Guarav's Building a Simple Task Scheduler in Windows Azure — which, as it turns out, is not that simple, and it is not really suited to Azure websites (but rather roles).

The simplest solution is to create RESTful (ish) routes (controllers, etc) using something like the MVC Web API and get a cron job scheduler to kick them off. Recently I have been using the Aditi cloud scheduler which kicks of those jobs for you, and is free (5000 calls per month) in the marketplace.

Solution 2

There is this new scheduler http://www.windowsazure.com/en-us/services/scheduler/

Windows Azure Scheduler allows you to invoke actions—such as calling HTTP/S endpoints or posting a message to a storage queue—on any schedule. With Scheduler, you create jobs in the cloud that reliably call services both inside and outside of Windows Azure and run those jobs on demand, on a regularly recurring schedule, or designate them for a future date. This service is currently available as a standalone API.

Solution 3

If you are using Azure Web Sites (and they are very good) then there is the new WebJobs feature that lets you poke a http(s) endpoint or run scripts on a schedule.

Solution 4

Web and Worker Roles are part of the Cloud Service model, and both exist and haven't gone anywhere.

As stated in the comments to your question, the portal does not facilitate construction of these roles; this is something you'd create, either through Visual Studio, Eclipse (worker role), or PowerShell.

And you don't need a worker role for background tasks. As mentioned in dozens of other answers, worker and web roles are templates for Windows Server virtual machines. Since the VMs are stateless and restart each time from the same baseline, the template shapes what gets installed at startup.

You can run background tasks as a thread in either a web role or worker role. So if you wanted to, you could run all your background tasks within the same web role instances as your web site.

I recommend working through some of the basic examples in the Azure Training Kit, which walk through creating different roles from Visual Studio.

Share:
10,534
Giedrius
Author by

Giedrius

Professional .NET Developer

Updated on June 05, 2022

Comments

  • Giedrius
    Giedrius almost 2 years

    Previously, there was worker role in Azure, now I can't see one - so what to use for background/scheduled tasks, like maintainance, email sending, etc, should I create virtual machine and create windows services there or is there easier way?

  • Giedrius
    Giedrius almost 11 years
    my web site will use websites feature - so as I understand it is not safe to do background tasks there, because application pool recycle could interrupt background task?
  • David Makogon
    David Makogon almost 11 years
    You never mentioned websites in your original question. Websites is not the place to set up background processing. I was merely pointing out that a worker role is not the only mechanism for background tasks. Many apps run their web apps in a Web Role, and sometimes create a separate Worker Role (with its own instances) to do background tasks, and that's not always necessary (it is for scaling purposes, but that's a different topic).
  • Giedrius
    Giedrius almost 11 years
    I was looking at Aditi cloud scheduler, but I can't see it in Azure adon store, may be it is available only in specific regions.
  • Simon Munro
    Simon Munro almost 11 years
    Took me a while to find it the first time... it's called 'scheduler' in the store