Overview
WebJobs is a complete compute solution on a managed platform. The runtime offers many choices on how your code can run (cron, service, manually). Using Azure Websites as a platform means that WebJobs inherits tons of cool features. Azure Scheduler brings a plethora of scheduling choices. The ASP.NET team built the WebJobs SDK, which makes writing code that interfaces with the different Azure components (Blob, Queues, Tables, Service Bus) a snap! And the rich Visual Studio tooling wraps everything together seamlessly. Goes to show that sometimes the whole is bigger than the sum of its parts.
What is “WebJobs”?
Put simply, if you can run a program or script on your local machine, all you need to get it running on the cloud is upload it. It really is that easy! It will take less than 5 minutes from signing up on Azure to uploading and running your code. WebJobs is what you get when you cross a fully featured and managed cloud-based hosting platform with a generic compute environment. In other words, WebJobs is compute on a managed platform. Everything to make your code run, and keep it running is managed for you. All you have to do is put your program in a folder.
Your code on the cloud
By executing your program in WebJobs, since it runs on the cloud, your program can be scaled to multiple machines. Scaling effectively replicates, parallelizes, and adds load balancers to optimize performance. It is even possible to distribute the work globally using Azure Traffic Manager, or connect it to your own servers via Azure Websites’ VNET. WebJobs run on Azure Websites, which provides the infrastructure and access to a plethora of features.
Tools
Good tools are essential, so WebJobs support has been integrated directly into Visual Studio. From Visual Studio you can create a new project of type ‘WebJobs’ and publish the code directly onto Azure. You can even attach a remote debugging session to step through your code as it runs live on the cloud!
To make coding easier there is also a WebJobs SDK that greatly simplifies common tasks. The WebJobs SDK is basically an abstraction on top of the Azure SDK. It allows you to bind complex tasks and objects to C# primitives. That way, you don’t have to figure out how it all works, just use it.
Monitoring and Debugging
WebJobs also includes a way to monitor, debug and optimize your running code via a dedicated dashboard. The WebJobs dashboard lets you dig into every detail of your code as it runs. You can see every function, when they ran, with what parameters, for how long, and the call stack – all at runtime! Not to mention the remote debugging capabilities that lets you step into the code running on the cloud just as if it were running on your local machine.
Runtime
To top it all off, WebJobs can be run in a variety of different ways. They can be run manually, via an API, concurrently with a website, continuously (with the help of the “Always On” feature), or on a schedule. WebJobs can be scheduled to run once at a given time, or periodically on a schedule. The scheduling is done via the Azure Scheduler, which offers just about every permutation of scheduling options one can think of.
More…
Nearly every component in WebJobs is optional and can function independently so you have the flexibility to work the way you like. There are tons of details and use cases for WebJobs, much of this is covered in Azure WebJobs Recommended Resources. It’s important to note that for the best experience, make sure you have the latest Visual Studio update as well as the latest Azure SDK and WebJobs SDK.
The Big List
Runtime |
| SDK |
| Visual Studio | |||
Triggered (Scheduled / OnDemand) | Bindings | Publish WebJobs | |||||
| Access to System logs and user output |
| Blobs, Tables, Queues, Service Bus |
| Publish WebJobs with Web Site | ||
Graceful shutdown | Binds to C# primitives | Publish Console Apps as WebJobs | |||||
Webhook for notifications | ie. Stream, string, TextReader/writer, etc… | Continuous WebJobs | |||||
Parameter passing as arguments | Parallelism |
| Start & Stop | ||||
Run manually (on demand) |
| Single or multiple Queue items | View Dashboard | ||||
Scheduled to Run at a specified time | Parallel processing of Queue items | Attach Debugger | |||||
Scheduled Run repeatedly | Poison message handling for Queues/ Blobs | Triggered WebJobs | |||||
Advanced scheduling /Azure Scheduler | Async functions |
| Run | ||||
Configurable retry and error actions | Triggers (Azure storage and Service bus) | View Dashboard | |||||
Continuous (or Contiguous) |
| on new for Queues, Blobs, Service Bus | WebJobs new project templates | ||||
| Access to System logs and user output | on modify for Blob |
| Scheduled & Continuous | |||
Singleton or parallel mode | Monitoring for WebJobs | Server Explorer integration | |||||
Graceful shutdown |
| At the function level, invocation, parameters |
| Right-click remote debugging from VS | |||
Works for “Always On” for continuity | ie. Execution time, I/O, basic profile, etc … | ||||||
Settings file (optional) | Dashboard for WebJobs | Other Features | |||||
Configurable restart time and timeouts |
| Invoke and Replay | |||||
History size for triggered (# runs) | Causality (chaining) between functions | Some inherited features from Azure Websites | |||||
Stacks supported | Search blobs |
| Visual Studio Online can edit scripts | ||||
| cmd, bat, exe, ps1, sh, php, py, js, jar… | Error handling | Auto scale (monitors CPU, resources or schedule) | ||||
API |
| Retries | Share environment variables with Websites | ||||
| REST API, Powershell | WebJobs shutdown support | Deployment options, features & tools | ||||
Dashboard | Process explorer shows CPU and other resources | ||||||
| Monitoring & diagnostics | Azure Traffic Manager for geo-distribution |