Building Distributed Cloud Apps With Azure WebSites, WebJobs And Azure Service Bus Topic
In my previous blog post, Building Distributed Cloud Apps With Azure Cloud Services And Azure Service Bus Topic, I have introduced a reference Azure app for developing multi-tiered distributed apps using Azure Cloud services and Azure Service Bus Topic. In that app, we have used two Azure worker roles for running a background processing system and a Notification Hub. This app is same like the previous one, the only difference here is that we are replacing two Azure worker roles with two WebJobs and running in a Azure WebSite. In the previous system, we have used a one Azure web role and two Azure worker roles for an ordr processing demo app. Here we replace these three systems with one WebSite, which is also working as the host for two WebJobs. In short, we replace the worker role with WebJobs. The extra functionality which we have added in this version is the distributed caching with Azure Redis cache.
The project repository is available here: https://github.com/AccelNA/azure-guidance and the source code of this drop is available here: https://github.com/AccelNA/azure-guidance/tree/master/WebSite
Here is the infomration about the sample app:
Technologies:
- Azure Web Sites
- Azure WebJobs
- Azure Service Bus Topic
- Azure Notification Hub
- Azure DocumentDB
- Azure Redis Cache
Solution Architecture
Problem Domain
- Order processing app in a distributed computing environment.
- Application logic should be deployed into multiple components.
- An order request from customer, should notify to multiple systems – including order processing system and a Notification Hub.
- Cross platform mobile apps should be able to receive real-time push notifications from Cloud powered systems.
- A RESTful API for working as backend for mobile apps.
- Cost effectiveness is important for this system.
Solution Workflow
- End user submits an order through a web app, which is hosted in Azure Web Site. The Web Site is also hosting two WebJobs: a WebJob for performing order processing logic and another WebJob for sending real-time mobile push notifications.
- The Azure Web Site publishes a message into Azure Service Bus Topic for the subscribers of the distributed systems environment.
- A WebJob running in a Azure Web Site subscribes the message from Azure Service Bus Topic , and then process the order and finally persist the data into a NoSQL Database – Azure DocumentDB.
- A notification hub running in a WebJobs, subscribes the message from Azure Service Bus Topic, and then send cross platform, real-time push notifications to mobile apps running in Android, iOS and Windows Phone.
- The web app hosted in Azure Web Site shows the status of orders which is processed in the WebJob which performs order processing logic.
- Mobile apps are consuming REST API hosted in Azure web site.
Azure Services
- Web Site– Used for running web app for receiving orders from customers. The Web Site is also hosting two WebJobs.
- WebJob - WebJob - Background worker for receiving messages from Service Bus Topic and then processing the orders.
- WebJob - Background worker for receiving messages from Service Bus Topic and then sends real-time push notifications to 2. cross platform mobile apps.
- Service Bus – Working as a message broker
- Notification Hub – Sending cross platform push notifications.
- DocumentDB – NoSQL data store.
- Web Site – Used for running RESTful API.
- Redis Cache - Distributed caching.