The Power of the Worker Role: Windows Azure + Microsoft Dynamics CRM 2011 Better Together, Part Three

If you are using Windows Azure, then you have probably noticed huge amount of recent changes. We have a new portal which looks and functions very nicely, more IaaS, and a lot of extended capabilities. Scott Guthrie  published a summary article on his blog about new Azure 2.0 that is worth a look.

Let's than start with another part of Windows Azure that might be a very helpful for those of us working in Microsoft Dynamics world, the "Worker Role". (You can see our previous explorations on routing orders and brokered messaging also.)  It sounds very mysterious but it's actually simple and powerful at the same time. Worker roles are applications that are developed to run asynchronously and to work on long-running or perpetual tasks independent of user interaction or input.  I would definitely compare them to the older (before cloud era ) "Windows Service" . The beauty of the worker role comes also with interoperability - a worker role can host almost any type of application including Java-based, Apache Tomcat, .NET of course, even WCF web services.  

But enough theory let's present our...

Business Problem

Company XYZ is adding more and more customers and they need to perform more and more periodic jobs. Two of these jobs in particular are consuming a lot of resources. One is generation and transfer of invoices and the other is monitoring of their SLA's (Service Level Agreements).

Generation of invoices seems like a pretty simple job, but our company has many to prepare and they are generated as PDF files. That process happens only during the last two days of every month. In the old days they would have needed to invest in a new server to perform that task effectively and the server would be fully utilized over those two days only. Now they have access to the Windows Azure platform and worker roles.  The worker role is designed to execute long-running processes. It can connect to their Dynamics CRM systems, generate PDF files, and attach those PDFs to emails or SharePoint libraries.

And because a worker role uses the same principle as other Azure Services, it can be scaled on demand. Combining the strength of the Windows Azure Diagnostics API and the Service Management API makes really easy to implement custom logic for auto-scaling Azure Services. That means Company XYZ will pay only for effective usage of compute when they will need it. And  if suddenly the number of invoices increases, they will be able to handle that very quickly without ordering and waiting for new hardware. 

The worker role comes in very handy for all sorts of monitoring type activities. Usually in the Dynamics CRM world all kind of SLAs are handled by workflow and that works quite well usually. But workflows have some limitations when it comes to quick, scalable behaviour, and also it is difficult to run workflows across multiple instances of Dynamics CRM. For that reason, XYZ invested in one central, scalable SLA monitor in an Azure worker role that monitors not just Dynamics CRM cases, but also other systems. 

Summary

Worker roles can be very handy for Dynamics CRM implementations and other business applications that require periodic activities and reliable background processes. They provide effective scalability, very good elasticity, and full control over background processes. Yet again, Azure-plus-Dynanics CRM 2011 prove to be good match.

About Sebastian Waksmundzki

Sebastian Waksmundzki is a Microsoft Dynamics CRM solution architect. He is  strongly involved in .net, Azure, and XRM projects and simply loves his job.

He also blogs at MindTheCloud.net.

Read full bio...