Part 4 – Live Streaming Weather Station with Cortana Analytics (Online Data Analytics with Azure ML)

In previous posts, I have showed the process of creating a live weather data streaming with Cortana.


In Part 1 the process of setting up Raspberry PI3 and weather station sensor has been explained. Following, in Part 2, the process of setting up the Event Hub as a median to digest the data from Raspberry PI has been explained. The collected data has been send to the Stream Analytics for aim of streaming data to Power BI and Azure ML. The process of setting up Stream Analytics and how to show data in Power BI has been explained in Part 3.

There is a possibility to pass data to Azure Ml and do a live data Analytics for example classify the collected data into different Cluster. In this post I will show just the process sending data from Stream Analytics to Azure Ml and how call a predefined Azure ML web service. However, I am not going to show how to create a web service in Azure Ml but, in next series I will talk completely about Azure ML, Machine Learning, creating Web service and so on.


For sending data to Azure ML web service we need some information such as web service url and key. In Azure Ml after you creating the web service (I will explained this in next series), Azure provided you a URL and key . So first log in to your Azure Ml account, then go to web services section, and choose specific web service. I created a web service that get the temperature of weather and cluster it to identify this measurement is related to which cluster. this will help to see the temperature data trend and classify the temperature data.


then by clicking on then specific web service, in our case “weather azure”, you will access the created API (Web Service) Specifications. copy the API key. then click on the request and response (number 2)to fetch the API URL


by clicking on the “Request/Response” (number 2) you will see the an API documentation. In API documentation, you will see the “Post” url.


After copying the post url and key, now we are going to call this API with these specifications. In “Stream Analytics” specifications, click on the “Function” option. then click on the “Add” menu (see below picture)

by clicking on the “Add” function, you will see the below window. here in function alias, specify a name for function. then in “Function type” select ” Azure ML”. Then specify the subscription and put the web service API (you already fetch from Azure Ml website) also the API key, you should put it in “Key” place. then click on “Create” option to set up the web service.


by creating web service, you will see the web service specifications (number 1). as you see in below image, the created function accept one parameter (temperature), the out put is a record as it send the temperature and the Azure ML cluster number.


In the next step, we want to write a query to get data from Azure Event Hub and pass it to the Azure ML, the out put for Azure ML result can be shown in Power BI dashboard.

finally by clicking on the query we will see below windows. we should specify the output and input here.

the process of creating input and out put have been explained briefly in Part 3. here we get data from “event Hub” as input “iotevent” then we want to put the result of Azure ML in Power BI visualization dashboard.

hence in the query, we first fetch data from azure ml function by

WITH weatherpred AS (
select value, weatherpred(value)  as result  from iotevent

as you can see the “value” is input for our function and is one of the columns of data collected from Event Hub. Value has the measure for weather specifications such as temperature, humidity and so forth. so we pass the value input from event hub to Azure ML web service and created function in Stream analytics.

then we want to show the result of azure ML (which in this case is cluster number) into power bi dashboard, hence in select we have original value and the cluster number and we put the result into “powerbiazure”

Select value,result.[Assignments]
Into powerbiazure
From weatherpred where  result.[measurename]='Temperature'  ;

moreover, the only value that we want to pass to the Azure ML API is temperature so we exclude the others.

by “Starting” the Stream Analytics, the dataset in power bi is created and the result of azure Ml clustering will be shown .


This Series with four parts is now finished.

In next series I will start to talk about Azure ML environment, the upcoming series can contain of 6 or 7 parts that I will explain the Azure ML environment, algorithms, how to create models, evaluate model and enhance models in Azure ML, Azure ML components, API and so forth.


Leila Etaati on LinkedinLeila Etaati on TwitterLeila Etaati on Youtube
Leila Etaati
Trainer, Consultant, Mentor
Leila is the first Microsoft AI MVP in New Zealand and Australia, She has Ph.D. in Information System from the University Of Auckland. She is the Co-director and data scientist in RADACAD Company with more than 100 clients in around the world. She is the co-organizer of Microsoft Business Intelligence and Power BI Use group (meetup) in Auckland with more than 1200 members, She is the co-organizer of three main conferences in Auckland: SQL Saturday Auckland (2015 till now) with more than 400 registrations, Difinity (2017 till now) with more than 200 registrations and Global AI Bootcamp 2018. She is a Data Scientist, BI Consultant, Trainer, and Speaker. She is a well-known International Speakers to many conferences such as Microsoft ignite, SQL pass, Data Platform Summit, SQL Saturday, Power BI world Tour and so forth in Europe, USA, Asia, Australia, and New Zealand. She has over ten years’ experience working with databases and software systems. She was involved in many large-scale projects for big-sized companies. She also AI and Data Platform Microsoft MVP. Leila is an active Technical Microsoft AI blogger for RADACAD.

Leave a Reply