0
votes

Actually i am using Modbus simulator and sending data to azure iot hub.I am using azure stream analytics but i am not able to apply any quert on modbus data will it possible to apply azure stream analytics query on modbus data or opc ua simulated data there is only one query which can perform is select * and also will it be possible to find object value through azure analytics query. i am providing json value for reference { "body": { "PublishTimestamp": "2020-06-23 05:34:22", "Content": [ { "HwId": "PowerMeter-0a:01:01:01:01:01", "Data": [ { "CorrelationId": "DefaultCorrelationId", "SourceTimestamp": "2020-06-23 05:34:21", "Values": [ { "DisplayName": "humidity", "Address": "400002", "Value": "47" }, { "DisplayName": "Temperature", "Address": "400001", "Value": "78" } ] } ] } ] } } i need to find the value data through azure analytics query this is my query i am able to get the data till Content

SELECT body.Content FROM temperature

and when i am trying this query select body.Content.data.Values.Value FROM temperature

i am getting null as output

thanks in advance Avi

1
Hello Avinash, I think you need to put a bigger effort into explaining what you are asking. I'm not even sure you are asking anything other than for help. What rule are you referring to? Please write clear statements to explain your setup and add screenshots if necessary. - Marcos G.

1 Answers

0
votes

This is the only question I could find about this topic. I am working on basically the same thing: I am using using the Modbus module from Azure Marketplace in an IoT Edge application, and I wanted to parse out the incoming Modbus data from the IoT Hub so I can view it in a table, with each value referencing its associated HwId and Timestamp.

I think I found something that might work for you. You need to specify each of the nested JSON values as arrays using GetArrayElements:

SELECT
    ncontent.ArrayValue.HwId as HwId,
    ndata.ArrayValue.SourceTimestamp as [Timestamp],
    nvalues.ArrayValue.DisplayName as DisplayName,
    nvalues.ArrayValue.Address as Address,
    nvalues.ArrayValue.Value as Value
INTO
    <output>
FROM
    <input> i
    CROSS APPLY GetArrayElements(i.Content) as ncontent
    CROSS APPLY GetArrayElements(ncontent.ArrayValue.Data) as ndata
    CROSS APPLY GetArrayElements(ndata.ArrayValue.[Values]) as nvalues

Here is the output that I got in the Test results:

HwId     Timestamp               DisplayName    Address   Value
"HwId1"  "2020-06-26 19:16:31"   "HREG0002"     "40002"   "32019"
"HwId2"  "2020-06-26 19:16:31"   "HREG0005"     "40005"   "17506"
"HwId3"  "2020-06-26 19:16:31"   "HREG0008"     "40008"   "33352"