locked
Message routing to multiple endpoints from IoT hub RRS feed

  • Question

  • Hi,

    We have an IoT hub which is receiving data from multiple sources.

    The messages from a particular source has to be sent to two different endpoints.

    I've created two custom endpoints(storage accounts). When I create a 'custom route', one of the endpoints is selected and it is working(the query is based on the deviceID).

    I'm not sure what happens if I create the second 'custom route' by selecting the second endpoint with the same query.

    Could you please help me here?

    Thanks.


    • Edited by Prasanth E Monday, September 16, 2019 4:10 AM
    Monday, September 16, 2019 4:09 AM

Answers

  • Do not apologize your question was actually very clear. I don't know how I managed to lose the plot. My apologies. 

    No need to set content type or encoding for Json/utf 8 if queuing only on device twin in the route. Only query on body requires these values to be set. 

    Thanks again for your feedback, after your question a note was added to the documentation to clarify this.


    Tuesday, October 22, 2019 8:42 PM

All replies

  • It looks like these two storage accounts will be containing the same data? Are you experiencing any issues when testing this?
    Tuesday, September 17, 2019 12:25 AM
  • Hi Prasanth E just wanted to see if you resolved your issue?
    Tuesday, September 24, 2019 8:16 PM
  • Hello Alberto,

    My apologies for the delay.

    Creating the second custom route with the same query but selecting different endpoint does work. Thank you very much.

    I've another question related to this. If the route is based on the device twin of the IoT edge device, is it necessary that the message should be updated with the content type and content encoding?

    As per my understanding, they are needed if we are routing it based on the message body.

    Please correct me if I'm wrong.

    Regards,

    Prasanth E

    Friday, October 18, 2019 7:09 AM

  • *Edit:

    You are right: "To enable querying on message body, the message should be in a JSON encoded in either UTF-8, UTF-16 or UTF-32. The contentType must be set to application/JSON and contentEncoding to one of the supported UTF encodings in the system property. If these properties are not specified, IoT Hub will not evaluate the query expression on the message body."

    have you seen this example? https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/iot-hub/iot-hub-devguide-routing-query-syntax.md#message-routing-query-based-on-message-body

    I am assuming that query works when tested in the portal? 

    I believe that you are talking to support they should be able to further help or find you help from the product team. 


    Friday, October 18, 2019 6:48 PM
  • Also there is another way to do this using the message enrichment feature. (Not sure if you would be interested in evaluating this or not but I added it just in case) the difference I guess is that you have to add the Twin data to the message.

    If you are looking to do something like this. If you use message enrichment you can add Twin data to the message and then it would be available for you to query by that in the message itself. By using message enrichment you can stamp Twin data into the message.

    https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-message-enrichments-overview


    Friday, October 18, 2019 9:07 PM
  • Thank you very much for the response Alberto. I'll check the links that you've provided related to Message Enrichment.

    The actual question I was referring to was "Do we need to specify the contentEncoding and contentType if we are routing the messages based on Device Twin?" (- maybe I wasn't clear earlier-sorry)

    Regards,

    Prasanth E

    Monday, October 21, 2019 6:11 AM
  • Do not apologize your question was actually very clear. I don't know how I managed to lose the plot. My apologies. 

    No need to set content type or encoding for Json/utf 8 if queuing only on device twin in the route. Only query on body requires these values to be set. 

    Thanks again for your feedback, after your question a note was added to the documentation to clarify this.


    Tuesday, October 22, 2019 8:42 PM
  • Hi Alberto,

    Thanks for your guidance on this. I would like to update one info here as I did not find it in the MS documentation.

    I did implement the message routing based on tags added to the device twin. I have few devices that has few modules. The devices with the modules did not work with this routing. On checking with MS IoT Hub PG team, we've been told that if the device has modules, the routing query will look for the condition in the 'Module Twin' whereas if there are no modules, the routing query will look the condition in the 'device twin'

    Regards,

    Prasanth E



    • Edited by Prasanth E Friday, January 10, 2020 7:16 AM
    Friday, January 10, 2020 5:16 AM