Introduction
As the Internet of Things (IoT) is being embraced widely in the current technological revolution, along comes a huge volume of data getting generated from the things that are connected to the internet.
For such a huge volume of data to be analyzed in real time, Microsoft has provided a SAAS feature called Azure Stream Analytics.
Features of Azure Stream Analytics
- It is an engine to process live streams of data that are injected in to it.
- It can be configured to act on data injected in a certain period of any time unit like seconds, minutes, hours and days. The maximum number being 7 days.
- The input data can come from any of the Azure resources like Azure Event Hub, IoT hub and Blob Storage.
- The data getting injected are processed using SQL like queries and the output can be stored in any other Azure data storage platform like Cosmos DB, Storage Queue, Service Bus Queue Table Storage and many more.
Caveats of Azure Stream Analytics
- If you want to call any other services or access data that are beyond the capabilities of the ASA’s query then you shall go for Azure Functions.
- An event hub with a single consumer group cannot contain more than one trigger which means you cannot have a stream analytics job if you already have an Azure Function trigger hooked to the even hub.
Scenario
Enough of theory, let's now get practical with an example. Imagine there is a manufacturing organization with manufacturing plants all over a country. The plants will have trucks frequently leaving from it to supply the manufactured parts to the respective customers.
Whenever a truck leaves a plant details like the truck no., plant name, departure time and customer name would be sent to an Azure Event Hub which will then be analyzed through Azure Stream Analytics to capture the total number of trucks that have left from each plant to each customer and store the insight data in to Azure Cosmos DB.
Steps Involved
- Login to your Azure portal and create an Azure Event Hub namespace and Event Hub instance in it. I have created an event hub namespace called ContosoEventsNamespace and an event hub called ContosoTruckEvents.
- Create an Azure Cosmos DB SQL account called ContosoDB and new collections in it which will store the insights of the trucks utilizations.
- Create a Stream Analytics job called ContosoTrucksJob which will take the events posted to the event hub as the input data to analyze and post the output to the Cosmos DB SQL database.
- Configure the above created event hub as the input for the job as shown below,

- Configure the above created Cosmos DB SQL API as the output for the job as shown below,



Sai Kumar KoonaPosted Sep 17, 2018, 5:15 AM
Thanks for sharing.....