2
votes

Azure Web Jobs are a big time saver in that they solve the plumbing of triggers, continuous running, dashboard, etc. But I've only seen them run in Web sites. It'd be great to be able to move them to a Worker Role. Do you have suggestions about how to do it? I'd personally love to see how they implement it, so that I can replicate it in my worker role, without reinventing the wheel...

2

2 Answers

4
votes

The answer to the main question is No Azure WebJobs are part of Azure Websites and only run in an Azure Website context/host.

But Azure WebJobs SDK which is an SDK that allows you to write code that is triggered on Azure storage blobs/queues and Azure service bus queues including some great logging capabilities, can be used outside of Azure WebJobs and so they can run anywhere (locally, VMs, WebRoles).

It is important to understand that Azure WebJobs are a framework that is part of Azure Websites that allows (almost) any console application (and .bat, .php, .js, ... scripts) to run continuously or triggered (manually/scheduled).

WebJobs SDK and WebJobs are not dependent on each other although they work great together.

Also to see how it's implemented go to https://github.com/projectkudu/kudu as it's open sourced (for now The WebJobs part, SDK may be open sourced in the future).

3
votes

Yes, you can use Azure WebJobs outside of Azure Web Sites. You use the Azure WebJobs SDK to do so. There is a sample on MSDN on how to use the SDK in an console app. It then goes on to host it in a web site, but you can of course host it in other ways. There is another article, "Hosting Azure webjobs outside Azure, with the logging benefits from an Azure hosted webjob" that explicitly talks about using WebJobs outside of Azure. With a little work this should work in a Worker role as well.

I'll stipulate that I've not actually done this myself, but the SDK does make it possible.

I'd also recommend this treasure trove of resources for WebJobs.