简体   繁体   中英

Azure Stream Analytics filter IOT Hub input

I am trying to persist incoming IOT Hub D2C messages to an Azure Cosmos DB using Azure Stream Analytics. Every Azure Stream Analytics tutorial I can find assumes that messages incoming from the IOT Hub input are of the same shape, which is not true for my case (for testing purposes I am using the tempSensor module from the IOT Edge Module examples and another custom made module based on this tutorial ).

This is why I want to filter out the messages that I don't want to persist (ie the messages sent by the tempSensor module). In the documentation about using the IOT Hub as an Azure Stream Analysis input , a "StreamId" is mentioned:

"IoTHub.StreamId: A custom event property added by the sender device."

My idea is to use a WHERE clause in the Azure Stream Analytics query to only select messages that have a certain StreamId, but I have no Idea how to set this StreamId when sending a message from within my custom made IOT edge module.

  • How can I set the StreamId when sending a message to the IOT Hub from an IOT Edge Device?
  • Is there any other way to filter out unwanted messages?
  • How can I set the StreamId when sending a message to the IOT Hub from an IOT Edge Device?

UPDATE : It seems like document issue. It is not a system property in IoT Hub message, and we could not set value for this property. Microsoft will update the document. Appreciate your patience.

  • Is there any other way to filter out unwanted messages?

You can create a filter module in your device, and then configure the route for transmitting the D2C message to the filter. Here is a tutorial as reference.In this solution, .

You can deploy Azure Functions to filter sensor data on the IoT Edge device. Please refer to this document .

do you know all the messages you want to keep or to reject? If so you can also filter on the data (and not metadata). Especially if the messages all come from the same IoT Edge device, they may share some metadata. For example to filter out messages from the tempSensor module you can use this query:

SELECT * FROM input WHERE machine.temperature is NULL

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM