In this article I'm going to explain how to push data from iot devices through Azure Stream Analytics into multiples channels: Azure Blob Storage (as a cold database), Azure Cosmos DB (as a hot database), Power BI (for data visualization) and Azure Service Bus & Azure Logic App (data processing & user interaction).
2. 11/06/2019 Big Data class by Alexandre Bergere 2
Telemetry Stream Analytics
cold
hot
3. 11/06/2019 Big Data class by Alexandre Bergere 3
Build and deploy solution
For the puporse of the article, we will simulate a device through the Microsoft Azure device SDK for
Node.js. Our example will simulate a simple telemetry device, with the following structure:
azure-iot-sdk-node
{
“id”: “spaceneedle”
,temperature: 20 + (Math.random() * 10)
,localisation: {
type: “Point”
, coordinates: [2.3488, 48.8534]
}
,Owner: {
CompanyName: “Miscrosoft“
,id_companyName: “4309718283412”
}
}
4. 11/06/2019 Big Data class by Alexandre Bergere 4
Create a Power BI
account
https://signup.microsoft.com/signup?Sku=a403ebcc-fae0-4ca2-8c8c-7a907fd6c235&ru=https%3A%2F%25app.powerbi.com&pbi_source=ASA
5. 11/06/2019 Big Data class by Alexandre Bergere 5
real-time reporting
cold
hot
6. 11/06/2019 Big Data class by Alexandre Bergere 6
Azure IoT Hub creation
step 1
o Access to Azure portal : https://portal.azure.com/
o Launch the service “Iot hub”
7. 11/06/2019 Big Data class by Alexandre Bergere 7
Azure IoT Hub creation
step 1
o Create a new ressource group, which will be using for all the exercice
o Review + create
8. 11/06/2019 Big Data class by Alexandre Bergere 8
Azure IoT Hub creation
step 1
9. 11/06/2019 Big Data class by Alexandre Bergere 9
Azure IoT Hub device
creation
step 2
o Create a new device
10. 11/06/2019 Big Data class by Alexandre Bergere 10
Azure IoT Hub device
creation
step 2
In «IoT Devices » pane:
o ID: enter a name keep it in mind for the
other steps
o Authentication type: Symmetric Key
o Auto Generate keys: checked
o Connect device to IoT Hub : enable
11. 11/06/2019 Big Data class by Alexandre Bergere 11
Azure IoT Hub
configuration
step 3
In your new created device, copy the “Connection string (primary key)”
12. 11/06/2019 Big Data class by Alexandre Bergere 12
Link solution to Azure IoT
Hub
step 4
In your sdk code, paste the “Connection string (primary key)”
13. 11/06/2019 Big Data class by Alexandre Bergere 13
Blob Storage Creation
step 5
REST-based object storage for
unstructured data
Blob Storage
14. 11/06/2019 Big Data class by Alexandre Bergere 14
Blob Storage Creation
step 5
15. 11/06/2019 Big Data class by Alexandre Bergere 15
Create a blob storage
container
step 6
16. 11/06/2019 Big Data class by Alexandre Bergere 16
Cosmos DB Creation
step 7
Globally distributed, multi-model
database for any scale
Azure Cosmos DB
17. 11/06/2019 Big Data class by Alexandre Bergere 17
Cosmos DB Creation
step 7
For the purpose of this architecture we will
choose the Core(SQL) for the API.
19. 11/06/2019 Big Data class by Alexandre Bergere 19
Stream Analytics job
creation
step 8
20. 11/06/2019 Big Data class by Alexandre Bergere 20
Stream Analytics job
creation
step 8
o Name: choose a different name
o Subscription : choose between available subscriptions
o Resource group: select the previously created group
o Hosting environment: cloud
21. 11/06/2019 Big Data class by Alexandre Bergere 21
Stream Analytics job
configuration
step 8
22. 11/06/2019 Big Data class by Alexandre Bergere 22
Stream Analytics job
configuration
step 9
input : iot hub
23. 11/06/2019 Big Data class by Alexandre Bergere 23
Stream Analytics job
configuration
step 9
output : Blob storage
24. 11/06/2019 Big Data class by Alexandre Bergere 24
Stream Analytics job
configuration
step 9
output : Cosmos DB
o Document id: The name
of the field in output
events used to specify
the document id which
insert or update
operations are based
on.
In our example, we are
using the field “id” for that.
25. 11/06/2019 Big Data class by Alexandre Bergere 25
Stream Analytics job
configuration
step 9
output : Power BI
26. 11/06/2019 Big Data class by Alexandre Bergere 26
Stream Analytics job
configuration: query
step 10
27. 11/06/2019 Big Data class by Alexandre Bergere 27
Start Stream Analytics job
step 11
28. 11/06/2019 Big Data class by Alexandre Bergere 28
Launch app
step 12
Launch big_data_classes_iot_stream.js:
29. 11/06/2019 Big Data class by Alexandre Bergere 29
Verify
step 13
Check if the data is sending in blob storage account:
Blob should be appear in your container.
30. 11/06/2019 Big Data class by Alexandre Bergere 30
Power BI report: creation
step 14
31. 11/06/2019 Big Data class by Alexandre Bergere 31
Power BI report: creation
step 14
Iot-telemetry-stream
32. 11/06/2019 Big Data class by Alexandre Bergere 32
Power BI report: creation
step 14
33. 11/06/2019 Big Data class by Alexandre Bergere 33
Add devices
step 15
Add 2 or 3 devices:
o Copy – paste the “big_data_classes_iot_stream.js” in multiple files (one for
each future device)
o Change the coordinates point and device name.
o Add devices in iot hub
o Use the new connection string in your js file created earlier
o You could see your different device in Power BI
35. 11/06/2019 Big Data class by Alexandre Bergere 35
Service bus creation
step 1
36. 11/06/2019 Big Data class by Alexandre Bergere 36
o Name: choose a different name
o Pricing tier: Standard
o Subscription : choose between available subscriptions
o Resource group: select the previously created group
Service bus creation
step 1
37. 11/06/2019 Big Data class by Alexandre Bergere 37
Service bus configuration
step 2
Create a queue:
38. 11/06/2019 Big Data class by Alexandre Bergere 38
Stream Analytics
configuration: output
step 3
40. 11/06/2019 Big Data class by Alexandre Bergere 40
Logic app creation
step 4
o Name: choose a different name
o Subscription : choose between available subscriptions
o Resource group: select the previously created group
41. 11/06/2019 Big Data class by Alexandre Bergere 41
Logic app configuration
step 5
42. 11/06/2019 Big Data class by Alexandre Bergere 42
Logic app configuration
step 5
o Click on Create
o Select the service bus
youcreatedpreviously
o Select the
RootManageSharedAccessKeypolicy
o Give a name to the connection
o Select the queue
o Click on Next step and then in Add an
action
43. 11/06/2019 Big Data class by Alexandre Bergere 43
Logic app configuration
step 5
o Click on Next step and then in Add an
action
o Look for Office 365 Outlook connector
o Configure the « Send a email » box
44. 11/06/2019 Big Data class by Alexandre Bergere 44
Logic app configuration
step 5
o Configure the « Send a email » box
o Save the workflow, and run it
You can now follow the history of execution