This blog is an extraction of the webinar “Messaging Scenarios in Azure” presented by Steef-Jan Wiggers in episode 72 of Middleware Friday.
This blog covers few real-time scenarios and also a demo on Serverless Home Automation. Further, it discusses general considerations to choose messaging services available in Azure.
Cloud OCR Capability
Consider a real-time scenario of collecting a parking receipt. The submitted receipt would go to Microsoft Flow and gets stored in Azure Blob Storage in the next phase. An event is raised from the Blob Storage would reach Event Grid and also triggers a function. It is then sent to a Computer Vision API (OCR) to do Optical character recognition and finally gets transmitted to Service Bus Queue.
Provisioning Azure resources
This scenario is based on provisioning Azure resources. Out of the box, there is an API gateway which receives the message in a request and moves the messages to the Queue. The Web Job picks up the message from the Queue and subsequently provisions the Azure Storage and an SQL Instance in Elastic Pool. Now, both the connection strings are stored into the Key Vault. This architecture basically gives the ability for a multi-tenant solution to create Azure resources.
Data and event pipeline
Event Hubs captures the data from the stream and generates storage blobs with the data in Avro format. When the Event Hubs generates the blob, it triggers an event. Event Grid distributes data to the subscribers. In this case, the event data is sent to the Azure Functions endpoint. The event data includes the path of the generated blob. The function uses that URL to retrieve the file and send it to the data warehouse.
Serverless Home Automation
Let us assume, you have a house wired with devices that measure CO2 level, temperature and many more. You can push that data to IoT Hub which transfers the data to Event Hubs. The Event Hubs captures the data and also pushes it to the Functions, now the Functions will move the data into Cosmos DB.
Whenever the temperature changes, those data will end up in Cosmos DB. There is another Function which gets triggered every time a new data is entering the cosmos DB. This Function pushes the data to a Service Bus Queue and the Logic App notifies the house owner through SMS or an email.
The house owner could immediately respond to the situation to decrease the temperature or enable the air conditioner.
Demo on Serverless Home Automation
This demo contains a part of the complete solution where messaging is involved.
This is the Collection of temperature feed in Cosmos DB. For instance, change the temperature in the above code to 59.5 from 19.9 and also update it. Due to the change in temperature, it triggers the below Function.
This Function defines, if the temperature rises above 25-degreeCelsius generate a message in the Message Queue which will subsequently send the message to the owner as a notification.
This is the Logic App which is used to send the notification to the owner. When a message is received in a queue, the Logic App gets triggered and the Parse JSON action validates the message data and also sends notification as an email through Microsoft Outlook.
This Logic App, First, we have a Message Queue as a trigger which receives the message and stores in the queue.
In the next step, there is a Parse JSON action which processes the data and checks if the temperature is above 25-degree Celsius. In this case, the temperature is 59.5 so it sends an email to the owner.
This is the action which sends an email to the owner. The body of this action contains the temperature value which is sent to alert the owner.
These are the general considerations to choose messaging services.
Choose the right messaging service(s)
The messaging services compete and collaborate well together. You can have multiple Azure services within a solution like Event Hubs and Event Grids that we have seen in one of the above scenarios.
A workload is all about how much messages you are going to digest when you scale up with other microservices.
Security and compliance
You need to consider security and compliance regarding the messaging components and for an overall good solution.
If you must support cross-platform then Service Bus is the best option to choose.
Even though these services do not cost much. It is advisable to choose the service according to the architecture.
DevOps and Management
You should think about the DevOps and management of your service capability.
Messaging options in Microsoft Azure platform by Steef-Jan Wiggers.
A blog post on Durable Functions by Paco de la Cruz.
A two-day conference by AZUG starts on October 12, 2018.
Serverless360 is a one platform tool to operate, manage and monitor Azure Serverless components. It provides efficient tooling that is not and likely to be not available in Azure Portal. Try Serverless360 free for 15 days!