microsoft / vscode-asa

Azure Stream Analytics In VSCode
Creative Commons Attribution 4.0 International
10 stars 19 forks source link

Inlcude IoTHub properties (for example ConnectionDeviceId) when using local test data #52

Open ckarrasalithya opened 3 years ago

ckarrasalithya commented 3 years ago

I have a stream analytics queries that uses some IoTHub properties, for example:

SELECT IoTHub.ConnectionDeviceId AS DeviceId

However, when I preview data from IoT Hub and try to save the results to a JSON file for later reuse, the IoTHub properties are not included.

I also tried manually adding a "IoTHub.ConnectionDeviceId" property to every JSON record, and using that modified file as local test data for the query, but the query doesn't have access to that property.

The only way I could test the query was using live data. This works, but I would prefer using static data so that I can build a JSON file of "expected results" and then compare it to the actual results.

ckarrasalithya commented 3 years ago

I found a solution by using the Azure Portal to get sample data. In the JSON data file, the IoTHub properties have to be specified using a nested structure, for example:

{
   "timestamp": "2021-06-15T14:15:01.2820000Z",
   "value": 10,
      "IoTHub": {
        "ConnectionDeviceId": "DeviceId",
        "EnqueuedTime": "2021-06-15T14:15:11.5960000Z",
      }  
}

But it would still be useful if the VS Code extension had the ability to capture that data from IoT Hub to local JSON files for use in when testing with local data, instead of having to do that from the Azure portal.