Hello @JakobRasmusNrgaardHansenJRNHDK-3596 ,
you want to support multiple devices using a Azure Stream Analytics job sending data to Power BI.
Telemetry messages from the Azure IoT Hub contain IoT Hub related properties including the deviceId.
You already found out the GetMetadataPropertyValue function that gives access to the property bag.
The solution you show is not that scalable. Every time a device is added, you have to change the job.
This could be fixed by making the device ID part of the columns outputted:
SELECT
GetMetadataPropertyValue(inputiothub, 'IoTHub.ConnectionDeviceId') as deviceId,
temperature,
humidity,
pressure,
timestamp -- some datetime value?
INTO
outputpbi
FROM
inputiothub
I'm not sure what the value of the partitionId is for you, so I reused the same name. And I added a column representing the date and time.
Now you can filter on specific devices in powerBI while the job keeps supporting any new deviceId.
One step further is to group devices using the device twin tags and enriching IoT Hub messages with these tags.
Using this structure, you are able to make subgroups of devices and either aggregate in Azure Stream Analytics or Power BI.
Now you are in full control of what telemetry is sent to PowerBI.