Live Air Quality display with ASA, Power BI and Azure IoT

Published Jul 22 2021 09:32 AM 1,780 Views
Senior Member

This article is the second part of a series (part 1) which explores an end-to-end pipeline to deploy an Air Quality Monitoring application using off-the-shelf sensors, Azure IoT Ecosystem and Python. In the previous article we explored why such a platform is useful and how to solve the first mile problem of building this platform, i.e. getting the sensor data to the cloud. Before beginning this article it is assumed that you understand the impact of the product and it's potential value in current times, met the prerequisites, and successfully deployed the AirQualityModule on the IoT edge device. This article will show how to consume the data from the IoT hub, clean, summarize, and display the metrics on a dashboard.

 

What are ASA and Power BI?

Azure Stream Analytics (ASA)  is an easy-to-use, real-time analytics service that is designed for mission-critical workloads. Power BI is the visualization layer that unifies data from many sources and provides insights. Refer to  ASA and Power BI for pricing and documentation. 

 

To really appreciate the Azure infrastructure, let us take a small step back and understand what it means to say 'Data is the new Oil'.  What does Oil (Data) exactly do? It enables businesses to move faster, create actionable insights faster, and stay ahead of the competition. For obvious reasons, the business needs the  pipelines taking Oil (Data) from production to consumption in a smooth and regulated way. The problem is that this seemingly 'smooth' process is a complex labyrinth of interwoven Oil (Data) Engineering pipelines that can potentially make or break the business. This means you have to be very careful and judicious when you choose your Oil (Data) Engineering tools for your clients. I experimented with a lot of products, and found ASA and Power BI to be best in class for real time data processing and visualization. Here is a diagramatic view of ASA's capabilities and its place in the Azure Ecosystem.

 

maxresdefault.jpg

 

Some other notable mentions are Druid with SupersetInfluxDB/Azure Data Explorer (here) with Grafana, or even Cosmos DB (here) with React app. The deep integration of ASA and Power BI with the IoT ecosystem, and the ease of scaling with SLA are simply unbeatable in terms of turn-around time for the client. I highly recommend to use these products.

 

Preparing to consume

Here is the reference architecture for our current platform taken from part 1 of the series.

KaushikRoy_0-1626731489920.png

 

The data generated in the AirQualityModule uses message ROUTE mentioned in the IoT edge deployment. In a practical setting, this will almost never be the only module running on the edge device. More than one module could be sending data upstream to the IoT hub. For example here are the routes in my deployment. Notice the '$upstream' identifier. Refer here.

 

 

        "routes": {
          "AVAToHub": "FROM /messages/modules/avaedge/outputs/* INTO $upstream",
          "AirQualityModuleToIoTHub": "FROM /messages/modules/AirQualityModule/outputs/airquality INTO $upstream",
          "FaceDetectorToIoTHub": "FROM /messages/modules/FaceDetector/outputs/* INTO $upstream"
        }

 

 

Here I have an object detector module running alongside, sending inference data to the same IoT hub. Thus my IoT hub is receiving both these events. 

 

 

[{
    "temperature": 26.11,
    "pressure": 1003.76,
    "humidity": 39.26,
    "gasResistance": 274210,
    "IAQ": 129.1,
    "iaqAccuracy": 1,
    "eqCO2": 742.22,
    "eqBreathVOC": 1.05,
    "sensorId": "roomAQSensor",
    "longitude": -79.02527,
    "latitude": 43.857989,
    "cpuTemperature": 27.8,
    "timeCreated": "2021-07-20 04:11:23",
    "EventProcessedUtcTime": "2021-07-20T05:09:32.7707113Z",
    "PartitionId": 1,
    "EventEnqueuedUtcTime": "2021-07-20T04:11:23.5100000Z",
    "IoTHub": {
      "MessageId": null,
      "CorrelationId": null,
      "ConnectionDeviceId": "azureiotedge",
      "ConnectionDeviceGenerationId": "637614793098722945",
      "EnqueuedTime": "2021-07-20T04:11:23.5150000Z",
      "StreamId": null
    }
  },
  {
    "timestamp": 146407885400877,
    "inferences": [
      {
        "type": "entity",
        "subtype": "vehicleDetection",
        "entity": {
          "tag": {
            "value": "vehicle",
            "confidence": 0.57830006
          },
          "box": {
            "l": 0.34658492,
            "t": 0.6101173,
            "w": 0.047571957,
            "h": 0.040370107
          }
        }
      }
    ],
    "EventProcessedUtcTime": "2021-07-20T05:09:32.7707113Z",
    "PartitionId": 1,
    "EventEnqueuedUtcTime": "2021-07-20T04:11:22.8320000Z",
    "IoTHub": {
      "MessageId": "4f12572a-aa87-4d87-b46f-ebd658ec3d8f",
      "CorrelationId": null,
      "ConnectionDeviceId": "azureiotedge",
      "ConnectionDeviceGenerationId": "637599997588483809",
      "EnqueuedTime": "2021-07-20T04:11:22.8400000Z",
      "StreamId": null
    }
  }
]

 

 

Notice that the two blocks have totally different structures. Similarly there can be many more, and whatever data layer you create on top of this must cater to the dynamic and asynchronous nature of the input. This is where ASA shines and we will see how.

 

Real time IoT hub data processing with ASA

Processing data real time is never easy, no matter what tool we use. Fortunately Azure has provided us with common solution patterns and best practices regarding ASA here.  You have a few good options depending on what you are comfortable with. 

  1. Process the data using an ASA job as a UDF in C# (here)
  2. Process the data using Azure functions which can be in Python (here)
  3. Process the data using ASA Streaming Query Language (here)

You can add optional layers of RDBMS/Big Data/NoSql to persist the data, but for our current activity one of the above 3 is fine. My choice was the 3rd option since the resultant pipeline remains lightweight, and ASA SQL is just so powerful! 

 

Before we move on here are the sequence of steps you need to follow to implement this successfully.

  1. Check the IoT hub endpoint for messages from AirQualityModule
  2. Create ASA cloud job following the guides here and here
  3. Configure IoT Hub as input with JSON format
  4. Configure output to send to Power BI dashboard
  5. Create Query using temporary resultset and window functions
  6. Save the query and test using ASA interface
  7. Start the job to set it to running state
  8. Monitor ASA job for resource utilization
  9. Go to Power BI screen and check ASA output in workspace
  10. Create dashboard displaying Air Quality metrics
  11. Share Power BI dashboard with end user

 

Let us go through the steps in details. Step 1 you can check using VSCode to consume the endpoint option within the IoT tools extension. The required output is part of the two json outputs shown above. We will see how to separate those two soon. For step 2 you can create an ASA job through the portal or marketplace. You can automate this, but the portal is enough for our purpose. Call it anything you want (airqualitymetrics), use the 'cloud' option (important) and 3 streaming units (SUs). Technically you can do with less, but its a good habit to keep some buffer.

 

KaushikRoy_0-1626828380601.png

 

For steps 3 you can configure the IoT hub option. Notice the serialization format is set to 'JSON'. Clicking on 'Test' should say 'succeeded' a bit later.

KaushikRoy_1-1626828670920.png

 

For step 4 you can have as many outputs as you want, at least one of which should be Power BI. Put in the appropriate workspace and dataset name. 'Test' it. This output name 'sensordata' is how it will appear in your Power BI app when you log into it.

KaushikRoy_2-1626828751067.png

 

Step 5 is where all the magic happens. With one compact ASA query shown below you can accomplish the following tasks:

  • Create a temporary result for your air quality metrics (or other modules)
  • Apply data cleaning/sanitization/aliasing to the values inside
  • Compress high frequency data using tumbling window of 30 seconds
  • Create final outputs from querying temporary results 

 

 

WITH 
AirQuality AS (
SELECT
    sensorId
    ,System.Timestamp() AS OutTime
    ,ROUND(AVG(temperature),2) as temperature
    ,ROUND(AVG(pressure),2)  as pressure
    ,ROUND(AVG(humidity),2)  as humidity
    ,ROUND(AVG(gasResistance),2)  as gasResistance
    ,ROUND(AVG(IAQ),2)  as IAQ
    ,ROUND(AVG(iaqAccuracy),2)  as iaqAccuracy
    ,ROUND(AVG(eqCO2),2)  as eqCO2
    ,ROUND(AVG(eqBreathVOC),2)  as eqBreathVOC
    ,ROUND(AVG(cpuTemperature),2)  as cpuTemperature
    ,MAX(longitude) as longitude
    ,MAX(latitude) as latitude
FROM
    Inputstream TIMESTAMP BY IoTHub.EnqueuedTime
WHERE 
    sensorId is not null
GROUP BY sensorId,TumblingWindow(second,30)
)
,Faces AS (
select IoTHub.ConnectionDeviceId,
IoTHub.EnqueuedTime AS OutTime,
GetArrayElement(inferences,0).subtype,
GetArrayElement(inferences,0).entity.tag.value, 
GetArrayElement(inferences,0).entity.tag.confidence, 
GetArrayElement(inferences,0).entity.box.l, 
GetArrayElement(inferences,0).entity.box.t, 
GetArrayElement(inferences,0).entity.box.w, 
GetArrayElement(inferences,0).entity.box.h
from Inputstream timestamp by IoTHub.EnqueuedTime
where timestamp is not null)

SELECT * into powerbi2 from Faces where confidence>0.60
SELECT * into powerbi from AirQuality

 

 

If you followed all the steps correctly you should get data from the live stream in a 'Table' or 'Raw' format. Click on 'Save Query' to save and then 'Test Query' to actually run the above query on the live data. If all goes well you should get back test results as below.

KaushikRoy_3-1626837528980.png

Go back to the 'Overview' blade and click on 'Start' to start the job. Monitor the job for a couple of hours and you should can see the job state 'Running' and the utilization on the screen. This completes step 7 and 8.

KaushikRoy_4-1626837738171.png

 

After this go to the Power BI application and click on 'My Workspace'. If the ASA job is running then you will see the outputs as a 'Dataset' in your workspace. Note: If you don't see the output most probably the cause is the ASA job is not in a 'Running' state.

KaushikRoy_0-1626838999937.png

Click on 'Create' to start a dashboard and use a 'Published Dataset'. Here you can choose the 'sensordata' source. Remember this is configured in the ASA powerbi output in step 4. Step 9 is done.

KaushikRoy_1-1626839154494.png

Drag and drop a bunch of line charts from the vizualizations menu and click the appropriate checkboxes. Use the time axis to plot the values. Click on 'Save' to complete step 10.

KaushikRoy_2-1626839395852.png

 

Finally after all that effort we have the product ready for the end user! Just click on 'Share' and you have completed a production-ready scable end-to-end solution to display live air quality metrics using a simple off-the-market sensor and Azure IoT ecosystem. Here is how my final dashboard looks.

KaushikRoy_4-1626839624139.png

 

Future Work

I hope you enjoyed this series of articles on a complete AIr Quality monitoring application. We love to share our experiences and get feedback from the community as to how we are doing. Look out for upcoming articles and have a great time with Microsoft Azure.

To learn more about Microsoft apps and services, contact us at contact@abersoft.ca or 1-833-455-1850!

 

Please follow us here for regular updates: https://lnkd.in/gG9e4GD and check out our website https://abersoft.ca/ for more information!

 

%3CLINGO-SUB%20id%3D%22lingo-sub-2563638%22%20slang%3D%22en-US%22%3ELive%20Air%20Quality%20display%20with%20ASA%2C%20Power%20BI%20and%20Azure%20IoT%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2563638%22%20slang%3D%22en-US%22%3E%3CP%3EThis%20article%20is%20the%20%3CSTRONG%3Esecond%3C%2FSTRONG%3E%20part%20of%20a%20series%20(%3CA%20title%3D%22part%201%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Finternet-of-things%2Fdesign-a-azure-iot-indoor-air-quality-monitoring-platform-from%2Fba-p%2F2549733%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%3Epart%201%3C%2FA%3E)%20which%20explores%20an%20end-to-end%20pipeline%20to%20deploy%20an%20%3CSTRONG%3EAir%20Quality%20Monitoring%3C%2FSTRONG%3E%20application%20using%20off-the-shelf%20sensors%2C%20Azure%20IoT%20Ecosystem%20and%20Python.%20In%20the%20previous%20article%20we%20explored%20why%20such%20a%20platform%20is%20useful%20and%20how%20to%20solve%20the%20first%20mile%20problem%20of%20building%20this%20platform%2C%20i.e.%20getting%20the%20sensor%20data%20to%20the%20cloud.%20Before%20beginning%20this%20article%20it%20is%20assumed%20that%20you%20understand%20the%20impact%20of%20the%20product%20and%20it's%20potential%20value%20in%20current%20times%2C%20met%20the%20%3CSTRONG%3Eprerequisites%3C%2FSTRONG%3E%2C%20and%20successfully%20deployed%20the%20%3CSTRONG%3EAirQualityModule%3C%2FSTRONG%3E%20on%20the%20IoT%20edge%20device.%20This%20article%20will%20show%20how%20to%20consume%20the%20data%20from%20the%20IoT%20hub%2C%20clean%2C%20summarize%2C%20and%20display%20the%20metrics%20on%20a%20dashboard.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-293262154%22%20id%3D%22toc-hId-293262154%22%3EWhat%20are%20ASA%20and%20Power%20BI%3F%3C%2FH4%3E%0A%3CP%3EAzure%20Stream%20Analytics%20(ASA)%26nbsp%3B%20is%20an%20easy-to-use%2C%20real-time%20analytics%20service%20that%20is%20designed%20for%20mission-critical%20workloads.%20Power%20BI%20is%20the%20visualization%20layer%20that%20unifies%20data%20from%20many%20sources%20and%20provides%20insights.%26nbsp%3BRefer%20to%26nbsp%3B%20%3CA%20title%3D%22ASA%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fstream-analytics%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EASA%3C%2FA%3E%26nbsp%3Band%20%3CA%20title%3D%22Power%20BI%22%20href%3D%22https%3A%2F%2Fpowerbi.microsoft.com%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EPower%20BI%3C%2FA%3E%20for%20pricing%20and%20documentation.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20really%20appreciate%20the%20Azure%20infrastructure%2C%20let%20us%20take%20a%20small%20step%20back%20and%20understand%20what%20it%20means%20to%20say%20'%3CSTRONG%3EData%20is%20the%20new%20Oil%3C%2FSTRONG%3E'.%26nbsp%3B%20What%20does%20%3CSTRONG%3EOil%3C%2FSTRONG%3E%20(%3CSTRONG%3EData%3C%2FSTRONG%3E)%20exactly%20do%3F%20It%20enables%20businesses%20to%20move%20faster%2C%20create%20%3CSTRONG%3Eactionable%20insights%3C%2FSTRONG%3E%20faster%2C%26nbsp%3Band%26nbsp%3B%3CSTRONG%3Estay%20ahead%20of%20the%20competition%3C%2FSTRONG%3E.%20For%20obvious%20reasons%2C%20the%20business%20needs%20the%26nbsp%3B%20%3CSTRONG%3Epipelines%3C%2FSTRONG%3E%20taking%20Oil%20(Data)%20from%20%3CSTRONG%3Eproduction%20to%20consumption%3C%2FSTRONG%3E%20in%20a%20smooth%20and%20regulated%20way.%26nbsp%3BThe%20problem%20is%20that%20this%20seemingly%20%3CSTRONG%3E'smooth'%3C%2FSTRONG%3E%20process%20is%20a%20complex%20labyrinth%20of%20interwoven%20Oil%20(Data)%20Engineering%20pipelines%20that%20can%20potentially%20make%20or%20break%20the%20business.%20This%20means%20you%20have%20to%20be%20very%20careful%20and%20judicious%20when%20you%20choose%20your%20Oil%20(Data)%20Engineering%20tools%20for%20your%20clients.%26nbsp%3BI%20experimented%20with%20a%20lot%20of%20products%2C%20and%20found%20%3CSTRONG%3EASA%3C%2FSTRONG%3E%20and%20%3CSTRONG%3EPower%20BI%3C%2FSTRONG%3E%20to%20be%20%3CSTRONG%3Ebest%20in%20class%20%3C%2FSTRONG%3Efor%3CSTRONG%3E%20real%20time%20%3C%2FSTRONG%3Edata%20%3CSTRONG%3Eprocessing%20%3C%2FSTRONG%3Eand%20%3CSTRONG%3Evisualization%3C%2FSTRONG%3E.%20Here%20is%20a%20diagramatic%20view%20of%20ASA's%20capabilities%20and%20its%20place%20in%20the%20Azure%20Ecosystem.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22maxresdefault.jpg%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296920i6EA7D964E8574253%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22maxresdefault.jpg%22%20alt%3D%22maxresdefault.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESome%20other%20notable%20mentions%20are%20%3CSTRONG%3EDruid%3C%2FSTRONG%3E%20with%20%3CSTRONG%3ESuperset%3C%2FSTRONG%3E%2C%26nbsp%3B%3CSTRONG%3EInfluxDB%2FAzure%20Data%20Explorer%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fdata-explorer%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E)%20with%20%3CSTRONG%3EGrafana%3C%2FSTRONG%3E%2C%20or%20even%20%3CSTRONG%3ECosmos%20DB%3C%2FSTRONG%3E%26nbsp%3B(%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fazure.microsoft.com%2Fservices%2Fcosmos-db%2F%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E)%20with%20%3CSTRONG%3EReact%20%3C%2FSTRONG%3Eapp.%20The%20deep%20%3CSTRONG%3Eintegration%3C%2FSTRONG%3E%20of%20ASA%20and%20Power%20BI%20with%20the%20IoT%20ecosystem%2C%20and%20the%20ease%20of%20%3CSTRONG%3Escaling%3C%2FSTRONG%3E%20with%26nbsp%3B%3CSTRONG%3ESLA%3C%2FSTRONG%3E%26nbsp%3Bare%20simply%20unbeatable%20in%20terms%20of%20turn-around%20time%20for%20the%20client.%20I%20highly%20recommend%20to%20use%20these%20products.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--1514192309%22%20id%3D%22toc-hId--1514192309%22%3EPreparing%20to%20consume%3C%2FH4%3E%0A%3CP%3EHere%20is%20the%20reference%20architecture%20for%20our%20current%20platform%20taken%20from%20%3CA%20title%3D%22part%201%22%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Finternet-of-things%2Fdesign-a-azure-iot-indoor-air-quality-monitoring-platform-from%2Fba-p%2F2549733%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%3Epart%201%3C%2FA%3E%20of%20the%20series.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22KaushikRoy_0-1626731489920.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296915i78DE9C9821CD1D28%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_0-1626731489920.png%22%20alt%3D%22KaushikRoy_0-1626731489920.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20data%20generated%20in%20the%26nbsp%3B%3CSTRONG%3EAirQualityModule%3C%2FSTRONG%3E%20uses%20message%20%3CSTRONG%3EROUTE%3C%2FSTRONG%3E%20mentioned%20in%20the%20IoT%20edge%20deployment.%20In%20a%20practical%20setting%2C%20this%20will%20almost%20never%20be%20the%20only%20module%20running%20on%20the%20edge%20device.%20More%20than%20one%20module%20could%20be%20sending%20data%20%3CSTRONG%3Eupstream%3C%2FSTRONG%3E%20to%20the%20%3CSTRONG%3EIoT%3C%2FSTRONG%3E%20%3CSTRONG%3Ehub%3C%2FSTRONG%3E.%20For%20example%20here%20are%20the%20routes%20in%20my%20deployment.%20Notice%20the%20%3CSTRONG%3E'%24upstream'%3C%2FSTRONG%3E%20identifier.%20Refer%20%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Fmodule-composition%3Fview%3Diotedge-2020-11%23declare-routes%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%20%20%20%20%20%20%20%20%22routes%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22AVAToHub%22%3A%20%22FROM%20%2Fmessages%2Fmodules%2Favaedge%2Foutputs%2F*%20INTO%20%24upstream%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22AirQualityModuleToIoTHub%22%3A%20%22FROM%20%2Fmessages%2Fmodules%2FAirQualityModule%2Foutputs%2Fairquality%20INTO%20%24upstream%22%2C%0A%20%20%20%20%20%20%20%20%20%20%22FaceDetectorToIoTHub%22%3A%20%22FROM%20%2Fmessages%2Fmodules%2FFaceDetector%2Foutputs%2F*%20INTO%20%24upstream%22%0A%20%20%20%20%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20I%20have%20an%20object%20detector%20module%20running%20alongside%2C%20sending%20inference%20data%20to%20the%20same%20IoT%20hub.%20Thus%20my%20IoT%20hub%20is%20receiving%20both%20these%20events.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-json%22%3E%3CCODE%3E%5B%7B%0A%20%20%20%20%22temperature%22%3A%2026.11%2C%0A%20%20%20%20%22pressure%22%3A%201003.76%2C%0A%20%20%20%20%22humidity%22%3A%2039.26%2C%0A%20%20%20%20%22gasResistance%22%3A%20274210%2C%0A%20%20%20%20%22IAQ%22%3A%20129.1%2C%0A%20%20%20%20%22iaqAccuracy%22%3A%201%2C%0A%20%20%20%20%22eqCO2%22%3A%20742.22%2C%0A%20%20%20%20%22eqBreathVOC%22%3A%201.05%2C%0A%20%20%20%20%22sensorId%22%3A%20%22roomAQSensor%22%2C%0A%20%20%20%20%22longitude%22%3A%20-79.02527%2C%0A%20%20%20%20%22latitude%22%3A%2043.857989%2C%0A%20%20%20%20%22cpuTemperature%22%3A%2027.8%2C%0A%20%20%20%20%22timeCreated%22%3A%20%222021-07-20%2004%3A11%3A23%22%2C%0A%20%20%20%20%22EventProcessedUtcTime%22%3A%20%222021-07-20T05%3A09%3A32.7707113Z%22%2C%0A%20%20%20%20%22PartitionId%22%3A%201%2C%0A%20%20%20%20%22EventEnqueuedUtcTime%22%3A%20%222021-07-20T04%3A11%3A23.5100000Z%22%2C%0A%20%20%20%20%22IoTHub%22%3A%20%7B%0A%20%20%20%20%20%20%22MessageId%22%3A%20null%2C%0A%20%20%20%20%20%20%22CorrelationId%22%3A%20null%2C%0A%20%20%20%20%20%20%22ConnectionDeviceId%22%3A%20%22azureiotedge%22%2C%0A%20%20%20%20%20%20%22ConnectionDeviceGenerationId%22%3A%20%22637614793098722945%22%2C%0A%20%20%20%20%20%20%22EnqueuedTime%22%3A%20%222021-07-20T04%3A11%3A23.5150000Z%22%2C%0A%20%20%20%20%20%20%22StreamId%22%3A%20null%0A%20%20%20%20%7D%0A%20%20%7D%2C%0A%20%20%7B%0A%20%20%20%20%22timestamp%22%3A%20146407885400877%2C%0A%20%20%20%20%22inferences%22%3A%20%5B%0A%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%22type%22%3A%20%22entity%22%2C%0A%20%20%20%20%20%20%20%20%22subtype%22%3A%20%22vehicleDetection%22%2C%0A%20%20%20%20%20%20%20%20%22entity%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%22tag%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22value%22%3A%20%22vehicle%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22confidence%22%3A%200.57830006%0A%20%20%20%20%20%20%20%20%20%20%7D%2C%0A%20%20%20%20%20%20%20%20%20%20%22box%22%3A%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22l%22%3A%200.34658492%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22t%22%3A%200.6101173%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22w%22%3A%200.047571957%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22h%22%3A%200.040370107%0A%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%5D%2C%0A%20%20%20%20%22EventProcessedUtcTime%22%3A%20%222021-07-20T05%3A09%3A32.7707113Z%22%2C%0A%20%20%20%20%22PartitionId%22%3A%201%2C%0A%20%20%20%20%22EventEnqueuedUtcTime%22%3A%20%222021-07-20T04%3A11%3A22.8320000Z%22%2C%0A%20%20%20%20%22IoTHub%22%3A%20%7B%0A%20%20%20%20%20%20%22MessageId%22%3A%20%224f12572a-aa87-4d87-b46f-ebd658ec3d8f%22%2C%0A%20%20%20%20%20%20%22CorrelationId%22%3A%20null%2C%0A%20%20%20%20%20%20%22ConnectionDeviceId%22%3A%20%22azureiotedge%22%2C%0A%20%20%20%20%20%20%22ConnectionDeviceGenerationId%22%3A%20%22637599997588483809%22%2C%0A%20%20%20%20%20%20%22EnqueuedTime%22%3A%20%222021-07-20T04%3A11%3A22.8400000Z%22%2C%0A%20%20%20%20%20%20%22StreamId%22%3A%20null%0A%20%20%20%20%7D%0A%20%20%7D%0A%5D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENotice%20that%20the%20%3CSTRONG%3Etwo%20blocks%3C%2FSTRONG%3E%20have%20totally%20%3CSTRONG%3Edifferent%3C%2FSTRONG%3E%20structures.%20Similarly%20there%20can%20be%20many%20more%2C%20and%20whatever%20%3CSTRONG%3Edata%20laye%3C%2FSTRONG%3Er%20you%20create%20on%20top%20of%20this%20must%20cater%20to%20the%20%3CSTRONG%3Edynamic%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Easynchronous%3C%2FSTRONG%3E%20nature%20of%20the%20input.%20This%20is%20where%20ASA%20shines%20and%20we%20will%20see%20how.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId-973320524%22%20id%3D%22toc-hId-973320524%22%3EReal%20time%20IoT%20hub%20data%20processing%20with%20ASA%3C%2FH4%3E%0A%3CP%3EProcessing%20data%20real%20time%20is%20never%20easy%2C%20no%20matter%20what%20tool%20we%20use.%20Fortunately%20Azure%20has%20provided%20us%20with%20common%20solution%20patterns%20and%20best%20practices%20regarding%20ASA%20%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-solution-patterns%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E.%26nbsp%3B%20You%20have%20a%20few%20good%20options%20depending%20on%20what%20you%20are%20comfortable%20with.%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EProcess%20the%20data%20using%20an%20ASA%20job%20as%20a%20UDF%20in%20C%23%20(%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-edge-csharp-udf%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EProcess%20the%20data%20using%20Azure%20functions%20which%20can%20be%20in%20Python%20(%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-with-azure-functions%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E)%3C%2FLI%3E%0A%3CLI%3EProcess%20the%20data%20using%20ASA%20Streaming%20Query%20Language%26nbsp%3B(%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fstream-analytics-query%2Fstream-analytics-query-language-reference%3Ftoc%3Dhttps%253A%252F%252Fdocs.microsoft.com%252Fen-us%252Fazure%252Fstream-analytics%252Ftoc.json%26amp%3Bbc%3Dhttps%253A%252F%252Fdocs.microsoft.com%252Fen-us%252Fazure%252Fbread%252Ftoc.json%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E)%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EYou%20can%20add%20optional%20layers%20of%20RDBMS%2FBig%20Data%2FNoSql%20to%20persist%20the%20data%2C%20but%20for%20our%20current%20activity%20one%20of%20the%20above%203%20is%20fine.%20My%20%3CA%20title%3D%22choice%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstreaming-technologies%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Echoice%3C%2FA%3E%20was%20the%203rd%20option%20since%20the%20resultant%20pipeline%20remains%20lightweight%2C%20and%20%3CSTRONG%3EASA%20SQL%3C%2FSTRONG%3E%20is%20just%20so%20powerful!%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBefore%20we%20move%20on%20here%20are%20the%20%3CSTRONG%3Esequence%20of%20steps%3C%2FSTRONG%3E%20you%20need%20to%20follow%20to%20implement%20this%20successfully.%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CSTRONG%3ECheck%20the%20IoT%20hub%20endpoint%20for%20messages%20from%20AirQualityModule%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20ASA%20cloud%20job%20following%20the%20guides%20%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-quick-create-portal%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E%20and%20%3CA%20title%3D%22here%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-get-started-with-azure-stream-analytics%3FWT.mc_id%3Diot-20412-cxa-to-process-data-from-iot-devices%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehere%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EConfigure%20IoT%20Hub%20as%20%3CA%20title%3D%22input%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-add-inputs%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Einput%3C%2FA%3E%20with%20%3CA%20title%3D%22JSON%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-parsing-json%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EJSON%3C%2FA%3E%20format%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EConfigure%20%3CA%20title%3D%22output%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-define-outputs%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eoutput%3C%2FA%3E%20to%20send%20to%20Power%20BI%20%3CA%20title%3D%22dashboard%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-power-bi-dashboard%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Edashboard%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20Query%20using%20%3CA%20title%3D%22temporary%20resultset%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fstream-analytics-query%2Fwith-azure-stream-analytics%3Ftoc%3Dhttps%253A%252F%252Fdocs.microsoft.com%252Fen-us%252Fazure%252Fstream-analytics%252Ftoc.json%26amp%3Bbc%3Dhttps%253A%252F%252Fdocs.microsoft.com%252Fen-us%252Fazure%252Fbread%252Ftoc.json%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Etemporary%20resultset%3C%2FA%3E%20and%20%3CA%20title%3D%22window%20functions%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-window-functions%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ewindow%20functions%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ESave%20the%20query%20and%20%3CA%20title%3D%22test%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-test-query%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Etest%3C%2FA%3E%20using%20ASA%20interface%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CA%20title%3D%22Start%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstart-job%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EStart%3C%2FA%3E%20the%20job%20to%20set%20it%20to%20running%20%3CA%20title%3D%22state%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fjob-states%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Estate%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3E%3CA%20title%3D%22Monitor%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-monitoring%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EMonitor%3C%2FA%3E%20ASA%20job%20for%20resource%20utilization%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EGo%20to%20Power%20BI%20screen%20and%20check%20ASA%20output%20in%20workspace%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3ECreate%20dashboard%20displaying%20Air%20Quality%20metrics%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3CLI%3E%3CSTRONG%3EShare%20Power%20BI%20dashboard%20with%20end%20user%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%20us%20go%20through%20the%20steps%20in%20details.%20Step%201%20you%20can%20check%20using%20VSCode%20to%20consume%20the%20endpoint%20%3CA%20title%3D%22option%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fiot-edge%2Ftutorial-develop-for-linux%3Fview%3Diotedge-2020-11%23view-messages-from-device%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eoption%3C%2FA%3E%20within%20the%20IoT%20tools%20extension.%20The%20required%20output%20is%20part%20of%20the%20two%20json%20outputs%20shown%20above.%20We%20will%20see%20how%20to%20separate%20those%20two%20soon.%20For%20step%202%20you%20can%20%3CA%20title%3D%22create%22%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fstream-analytics%2Fstream-analytics-quick-create-portal%3FWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ecreate%3C%2FA%3E%20an%20ASA%20job%20through%20the%20portal%20or%20%3CA%20title%3D%22marketplace%22%20href%3D%22https%3A%2F%2Fazuremarketplace.microsoft.com%2Fmarketplace%2Fapps%2Fmicrosoft.streamanalyticsjob%3Ftab%3Doverview%26amp%3BWT.mc_id%3Diot-20412-cxa%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Emarketplace%3C%2FA%3E.%20You%20can%20automate%20this%2C%20but%20the%20portal%20is%20enough%20for%20our%20purpose.%20Call%20it%20anything%20you%20want%20(%3CSTRONG%3Eairqualitymetrics%3C%2FSTRONG%3E)%2C%20use%20the%20%3CSTRONG%3E'cloud'%3C%2FSTRONG%3E%20option%20(important)%20and%203%20%3CSTRONG%3Estreaming%20units%3C%2FSTRONG%3E%20(SUs).%20Technically%20you%20can%20do%20with%20less%2C%20but%20its%20a%20good%20habit%20to%20keep%20some%20buffer.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22KaushikRoy_0-1626828380601.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297214i8537D9C17D7CA095%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22KaushikRoy_0-1626828380601.png%22%20alt%3D%22KaushikRoy_0-1626828380601.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20steps%203%20you%20can%20configure%20the%20%3CSTRONG%3EIoT%20hub%3C%2FSTRONG%3E%20option.%20Notice%20the%20%3CSTRONG%3Eserialization%3C%2FSTRONG%3E%20format%20is%20set%20to%20%3CSTRONG%3E'JSON'%3C%2FSTRONG%3E.%20Clicking%20on%20%3CSTRONG%3E'Test'%3C%2FSTRONG%3E%20should%20say%20'succeeded'%20a%20bit%20later.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22KaushikRoy_1-1626828670920.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297215i5111405197C66358%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_1-1626828670920.png%22%20alt%3D%22KaushikRoy_1-1626828670920.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20step%204%20you%20can%20have%20as%20%3CSTRONG%3Emany%20outputs%3C%2FSTRONG%3E%20as%20you%20want%2C%20at%20least%20one%20of%20which%20should%20be%20%3CSTRONG%3EPower%20BI%3C%2FSTRONG%3E.%20Put%20in%20the%20appropriate%20%3CSTRONG%3Eworkspace%3C%2FSTRONG%3E%20and%20%3CSTRONG%3Edataset%3C%2FSTRONG%3E%20name.%20'Test'%20it.%20This%20output%20name%20%3CSTRONG%3E'sensordata'%3C%2FSTRONG%3E%20is%20how%20it%20will%20appear%20in%20your%20Power%20BI%20app%20when%20you%20log%20into%20it.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22KaushikRoy_2-1626828751067.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297216i80FDE5553704EA71%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_2-1626828751067.png%22%20alt%3D%22KaushikRoy_2-1626828751067.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EStep%205%20is%20where%20all%20the%20magic%20happens.%20With%20one%20compact%20ASA%20query%20shown%20below%20you%20can%20accomplish%20the%20following%20tasks%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ECreate%20a%20%3CSTRONG%3Etemporary%20result%3C%2FSTRONG%3E%20for%20your%20air%20quality%20metrics%20(or%20other%20modules)%3C%2FLI%3E%0A%3CLI%3EApply%20data%20%3CSTRONG%3Ecleaning%3C%2FSTRONG%3E%2Fsanitization%2Faliasing%20to%20the%20values%20inside%3C%2FLI%3E%0A%3CLI%3ECompress%20high%20frequency%20data%20using%20%3CSTRONG%3Etumbling%20window%3C%2FSTRONG%3E%20of%2030%20seconds%3C%2FLI%3E%0A%3CLI%3ECreate%20final%20%3CSTRONG%3Eoutputs%3C%2FSTRONG%3E%20from%20querying%20temporary%20results%26nbsp%3B%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3EWITH%20%0AAirQuality%20AS%20(%0ASELECT%0A%20%20%20%20sensorId%0A%20%20%20%20%2CSystem.Timestamp()%20AS%20OutTime%0A%20%20%20%20%2CROUND(AVG(temperature)%2C2)%20as%20temperature%0A%20%20%20%20%2CROUND(AVG(pressure)%2C2)%20%20as%20pressure%0A%20%20%20%20%2CROUND(AVG(humidity)%2C2)%20%20as%20humidity%0A%20%20%20%20%2CROUND(AVG(gasResistance)%2C2)%20%20as%20gasResistance%0A%20%20%20%20%2CROUND(AVG(IAQ)%2C2)%20%20as%20IAQ%0A%20%20%20%20%2CROUND(AVG(iaqAccuracy)%2C2)%20%20as%20iaqAccuracy%0A%20%20%20%20%2CROUND(AVG(eqCO2)%2C2)%20%20as%20eqCO2%0A%20%20%20%20%2CROUND(AVG(eqBreathVOC)%2C2)%20%20as%20eqBreathVOC%0A%20%20%20%20%2CROUND(AVG(cpuTemperature)%2C2)%20%20as%20cpuTemperature%0A%20%20%20%20%2CMAX(longitude)%20as%20longitude%0A%20%20%20%20%2CMAX(latitude)%20as%20latitude%0AFROM%0A%20%20%20%20Inputstream%20TIMESTAMP%20BY%20IoTHub.EnqueuedTime%0AWHERE%20%0A%20%20%20%20sensorId%20is%20not%20null%0AGROUP%20BY%20sensorId%2CTumblingWindow(second%2C30)%0A)%0A%2CFaces%20AS%20(%0Aselect%20IoTHub.ConnectionDeviceId%2C%0AIoTHub.EnqueuedTime%20AS%20OutTime%2C%0AGetArrayElement(inferences%2C0).subtype%2C%0AGetArrayElement(inferences%2C0).entity.tag.value%2C%20%0AGetArrayElement(inferences%2C0).entity.tag.confidence%2C%20%0AGetArrayElement(inferences%2C0).entity.box.l%2C%20%0AGetArrayElement(inferences%2C0).entity.box.t%2C%20%0AGetArrayElement(inferences%2C0).entity.box.w%2C%20%0AGetArrayElement(inferences%2C0).entity.box.h%0Afrom%20Inputstream%20timestamp%20by%20IoTHub.EnqueuedTime%0Awhere%20timestamp%20is%20not%20null)%0A%0ASELECT%20*%20into%20powerbi2%20from%20Faces%20where%20confidence%26gt%3B0.60%0ASELECT%20*%20into%20powerbi%20from%20AirQuality%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20you%20followed%20all%20the%20steps%20correctly%20you%20should%20get%20data%20from%20the%20live%20stream%20in%20a%20%3CSTRONG%3E'Table'%3C%2FSTRONG%3E%20or%20%3CSTRONG%3E'Raw'%3C%2FSTRONG%3E%20format.%20Click%20on%20%3CSTRONG%3E'Save%20Query'%3C%2FSTRONG%3E%20to%20save%20and%20then%20%3CSTRONG%3E'Test%20Query'%3C%2FSTRONG%3E%20to%20actually%20run%20the%20above%20query%20on%20the%20live%20data.%20If%20all%20goes%20well%20you%20should%20get%20back%20test%20results%20as%20below.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22KaushikRoy_3-1626837528980.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297249i7F1A2E7F08915F0D%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_3-1626837528980.png%22%20alt%3D%22KaushikRoy_3-1626837528980.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EGo%20back%20to%20the%20%3CSTRONG%3E'Overview'%3C%2FSTRONG%3E%20blade%20and%20click%20on%20%3CSTRONG%3E'Start'%3C%2FSTRONG%3E%20to%20start%20the%20job.%20Monitor%20the%20job%20for%20a%20couple%20of%20hours%20and%20you%20should%20can%20see%20the%20job%20state%20%3CSTRONG%3E'Running'%3C%2FSTRONG%3E%20and%20the%20%3CSTRONG%3Eutilization%3C%2FSTRONG%3E%20on%20the%20screen.%20This%20completes%20step%207%20and%208.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22KaushikRoy_4-1626837738171.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297252iA58011D53A2758A7%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_4-1626837738171.png%22%20alt%3D%22KaushikRoy_4-1626837738171.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAfter%20this%20go%20to%20the%20%3CSTRONG%3EPower%20BI%3C%2FSTRONG%3E%20application%20and%20click%20on%20%3CSTRONG%3E'My%20Workspace'%3C%2FSTRONG%3E.%20If%20the%20ASA%20job%20is%20running%20then%20you%20will%20see%20the%20outputs%20as%20a%26nbsp%3B%3CSTRONG%3E'Dataset'%3C%2FSTRONG%3E%20in%20your%20workspace.%20%3CSTRONG%3ENote%3A%3C%2FSTRONG%3E%20If%20you%20don't%20see%20the%20output%20most%20probably%20the%20cause%20is%20the%20ASA%20%3CSTRONG%3Ejob%3C%2FSTRONG%3E%20is%20%3CSTRONG%3Enot%3C%2FSTRONG%3E%20in%20a%20%3CSTRONG%3E'Running'%3C%2FSTRONG%3E%20state.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22KaushikRoy_0-1626838999937.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297258i51A22A844FB6BC59%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_0-1626838999937.png%22%20alt%3D%22KaushikRoy_0-1626838999937.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EClick%20on%20%3CSTRONG%3E'Create'%3C%2FSTRONG%3E%20to%20start%20a%20dashboard%20and%20use%20a%20%3CSTRONG%3E'Published%20Dataset'%3C%2FSTRONG%3E.%20Here%20you%20can%20choose%20the%20%3CSTRONG%3E'sensordata'%3C%2FSTRONG%3E%20source.%20Remember%20this%20is%20configured%20in%20the%20ASA%20%3CEM%3Epowerbi%3C%2FEM%3E%20output%20in%20step%204.%20Step%209%20is%20done.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22KaushikRoy_1-1626839154494.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297259i2DBD2D8BDD704085%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_1-1626839154494.png%22%20alt%3D%22KaushikRoy_1-1626839154494.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EDrag%20and%20drop%20a%20bunch%20of%20%3CSTRONG%3Eline%20charts%3C%2FSTRONG%3E%20from%20the%20vizualizations%20menu%20and%20click%20the%20appropriate%20%3CSTRONG%3Echeckboxes%3C%2FSTRONG%3E.%20Use%20the%20%3CSTRONG%3Etime%20axis%3C%2FSTRONG%3E%20to%20plot%20the%20values.%20Click%20on%20%3CSTRONG%3E'Save'%3C%2FSTRONG%3E%20to%20complete%20step%2010.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22KaushikRoy_2-1626839395852.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297260i232CEBE453F1293A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22KaushikRoy_2-1626839395852.png%22%20alt%3D%22KaushikRoy_2-1626839395852.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFinally%20after%20all%20that%20effort%20we%20have%20the%20product%20ready%20for%20the%20end%20user!%20Just%20click%20on%20%3CSTRONG%3E'Share'%3C%2FSTRONG%3E%20and%26nbsp%3Byou%20have%20completed%20a%20%3CSTRONG%3Eproduction-ready%20scable%20end-to-end%20solution%20to%20display%20live%20air%20quality%20metrics%3C%2FSTRONG%3E%20using%20a%20simple%20off-the-market%20sensor%20and%20Azure%20IoT%20ecosystem.%20Here%20is%20how%20my%20final%20dashboard%20looks.%3C%2FP%3E%0A%3CP%20align%3D%22center%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22KaushikRoy_4-1626839624139.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F297263i6874E212CBBE99D2%2Fimage-size%2Flarge%3Fv%3Dv2%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22KaushikRoy_4-1626839624139.png%22%20alt%3D%22KaushikRoy_4-1626839624139.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH4%20id%3D%22toc-hId--834133939%22%20id%3D%22toc-hId--834133939%22%3E%3CEM%3EFuture%20Work%3C%2FEM%3E%3C%2FH4%3E%0A%3CP%3EI%20hope%20you%20enjoyed%20this%20series%20of%20articles%20on%20a%20complete%20%3CSTRONG%3EAIr%20Quality%20monitoring%3C%2FSTRONG%3E%20application.%20We%20love%20to%20share%20our%20experiences%20and%20get%20feedback%20from%20the%20community%20as%20to%20how%20we%20are%20doing.%20Look%20out%20for%20upcoming%20articles%20and%20have%20a%20great%20time%20with%20Microsoft%20Azure.%3C%2FP%3E%0A%3CP%3ETo%20learn%20more%20about%20Microsoft%20apps%20and%20services%2C%20contact%20us%20at%20%3CA%20title%3D%22contact%40abersoft.ca%22%20href%3D%22mailto%3Acontact%40abersoft.ca%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Econtact%40abersoft.ca%3C%2FA%3E%20or%201-833-455-1850!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20follow%20us%20here%20for%20regular%20updates%3A%20%3CA%20title%3D%22https%3A%2F%2Flnkd.in%2FgG9e4GD%22%20href%3D%22https%3A%2F%2Flnkd.in%2FgG9e4GD%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Flnkd.in%2FgG9e4GD%3C%2FA%3E%20and%20check%20out%20our%20website%20%3CA%20title%3D%22https%3A%2F%2Fabersoft.ca%2F%22%20href%3D%22https%3A%2F%2Fabersoft.ca%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fabersoft.ca%2F%3C%2FA%3E%20for%20more%20information!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2563638%22%20slang%3D%22en-US%22%3E%3CDIV%20id%3D%22lia-teaserTinyMceEditorKaushikRoy_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22ss2.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F296815i64EBA5BC65ADDA38%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ss2.png%22%20alt%3D%22ss2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EManaging%20high%20frequency%20sensor%20data%20with%20real-time%20aggregation%2C%20augmentation%2C%20and%20visualization%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2563638%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20IoT%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20Streaming%20Analytics%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPower%20BI%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Jul 22 2021 12:54 PM
www.000webhost.com