Microsoft Azure Stack is an extension of Azure – bringing the agility and innovation of cloud computing to your on-premises environment and enabling the only hybrid cloud that allows you to build and deploy hybrid apps anywhere. We bring together the best of the edge and cloud to deliver Azure services anywhere in your environment.

Updates in Azure WebJobs SDK (1.1.0-alpha2)

We recently released a preview of the WebJobs SDK. In addition to other new features and bug fixes, the release also opens up a new extensibility model allowing you to write your own triggers and binders. In this latest release we have added more extension triggers and binders in addition to introducing the Singleton feature which allows you to declaratively specify that only a single instance of a particular job function should run at any given time, even across multiple scaled out instances.

You can download the WebJobs SDK from the NuGet gallery and can install these packages from the NuGet gallery using the NuGet Package Manager Console.

You can also specify a scope expression/value on the Singleton attribute which will ensure that all executions of the function at that scope will be serialized. For example, in the above code if the queue contains 3 messages in Regions “East”, “East” and “West” respectively, then the messages that have region “East” will be executed as serially while the message with region “West” will be executed in parallel with those. This is useful if your function needs to access other distributed resources or perform other operations that should not/cannot be performed concurrently. A full sample can be accessed here.

Timer Trigger now uses this singleton feature to ensure that only instance of the Timer Trigger fires when you scale out your workload to multiple instances. I.e., for a scheduled job, you don’t want multiple scaled out instances to be invoked for each schedule occurrence – you only want to be notified once.

Community spotlight: Redis Trigger

We wanted to highlight an example of a trigger authored by one of the community members using the new extensibility model. Jason Haley (@haleyjason) has written a Redis Trigger which you can use to trigger functions based on Redis events. For example, each time an item is inserted in Redis, your function can be triggered. You can find this open source project here and follow the progress.

New binder (SendGrid) added in the Nightly Builds

As part of going open source, we have been publishing our nightly builds to MyGet. Recently we added SendGrid binder which allows you to send emails using SendGrid.

Imagine a scenario where you have an order processing WebJob where the queue message contains the order information. You can send email on successful order processing and also notify yourself when an error happens.

The following code shows how you can easily integrate this in your WebJob. You need to install Microsoft.Azure.WebJobs.Extensions.SendGrid NuGet package.