Introduction
The capabilities of an Azure Stream Analytics Job are so many. Here, in this post, we are going to discuss a few of them. An Azure Stream Analytics is basically an engine that processes the events coming from the devices we have configured. It can be an Azure IoT Dev Kit (MXChip) or a Raspberry Pi or something else. The Stream Analytics Job has two vital parts -
- Input source
- Output source
The input source is the source of your streaming data, in my case, it is my IoT Hub. And the output source is the output that you are configuring. I had configured the output to save the data to an Azure SQL database. Let’s just finish the introduction part now and start creating our own Stream Analytics.

docs.microsoft.com
Background
I recently got my MXChip (Azure IoT Dev Kit) and I was surprised with the capabilities that the device can do. It has a lot of sensors within the device, like temperature, humidity, pressure, magnetometer, security, etc. Then, I thought it is time to play with this. So, the basic idea here was to,
- Configure the device to send the data to IoT Hub
- Select the IoT Hub as a stream input
- Send the output to an SQL Server database
In this article, we are going to concentrate on how to create a Stream Analytics Job and how you can configure the same to save the stream data to the SQL Server database.
Prerequisites
To do wonderful things, we always need some prerequisites.
- Azure Subscription
- MXChip Azure IoT Dev Kit
- An active IoT Hubows Driver Kit (WDK) 10
- IoT Core ADK Add-Ons
- Windows 10 IoT Core Packages
- The Raspberry Pi BSP
- Custom FFU image we have created
Creating the Azure Stream Analytics Job
Log into your Azure Portal and click on the Create a resource, and then search for the “Stream Analytics job”.

Once you clicked on the Create button, it is time to specify the details of your job.
- Job Name
- Subscription
- Resource Group
- Location
- Hosting Environment
I would strongly recommend you select the same resource group of your IoT Hub for the Stream Analytics Job as well so that you can easily delete the resources when there are not needed. Once the deployment is successful you can go to the resource overview and see the details.
Configure Inputs
In the left menu, you can see a section called Job topology, that’s where we are going to work. Basically, we will be setting the Inputs and Outputs and then we will be writing a query that can take the inputs and send the values to the configured output. Click on the Inputs label and click on Add stream input and then select the IoT Hub.

In the next screen, you will have options to select the existing IoT hub and to create a new IoT Hub. As I have already created an IoT hub, I would select the existing one.
Please note that you are allowed to use special characters in the Input alias field, but if you use such, please make sure to include the same inside [] in the query, which we will be creating later.
About the special characters in the Input alias field.
Once you have successfully configured the Inputs, you can go ahead and configure the outputs.
Configure Outputs
Click on the Outputs from the Job topology section and click Add, and then select "SQL Database".





Sourabh SharmaPosted Mar 23, 2021, 8:02 AM
Hi Sibeesh very helpful and informative. Only thing is My data was not inserted to db but in the output string from the test query it is saying "Success". Am I missing something ?
Mahesh ChandPosted Dec 15, 2018, 7:25 AM
Great article, as usual, Sibeesh.