How to handle two “Iot hub” devices in “stream ana

2019-06-09 13:58发布

I am using "stream analytics jobs" to visualize the data that comes from two different devices of an "iot hub", the device1 and the device2; the device1 sends the following message:

{"messageId": 5576, "deviceId": "Raspberry Pi Web", "rpm": 22.80972122577826, "torque": 72.65678451219686}

The device2 sends the following message:

{"messageId": 1272, "deviceId": "Raspberry Pi Web Client", "temperature": 23.815921380797004, "humidity": 78.7491052866882}

The messages are sent at the same time and when I want to visualize the data in power bi, I only see the keys of one of the messages, messageId, temperature, humidity, PartitionId. these keys belong to the message sent by the device2; but the messageId, rpm, torque, PartitionId keys that correspond to device1 do not appear.

The query I am using in the stream analytics job is the following:

SELECT
    *
INTO
    output
FROM
    input

My devices are simulated devices that I use and configure from the following link: https://azure-samples.github.io/raspberry-pi-web-simulator/#Getstarted

How can I see messages from two different devices in the same iot hub with stream analytics job?

Note: I am using F1 level in "IoT Hub"

I appreciate your help

1条回答
唯我独甜
2楼-- · 2019-06-09 14:46

In PowerBI, one dataset represents a single source of data and has to be in a format:

There are literally hundreds of different data sources you can use with Power BI. But regardless of where you get your data from, that data has to be in a format the Power BI service can use to create reports and dashboards.

Reference: dataset concept and data source for Power BI.

For your issue you can route two devices events to two Power BI dataset.(two outputs in ASA job).

The query looks like this:

SELECT
    *
INOT
    powerbi
FROM
    iothubevents
WHERE
    deviceId = 'Raspberry Pi Web'


SELECT
    *
INOT
    powerbidevice2
FROM
    iothubevents
WHERE
    deviceId = 'Raspberry Pi Web Client'

See these snapshots: In stream analytics job:

enter image description here

enter image description here

In Power BI:

enter image description here

enter image description here

查看更多
登录 后发表回答