1
votes

I have set Routes for update twin and select endpoint as events(default) supported by Iot hub but it is not working.

Here is in screenshot

screenshot

Am i doing anything wrong or something is missing ? Any advice or references to other material would be appreciated.

2
How do you receive these events? Can you show your code?Rita Han
@Rita Hab For receiving event i use azure function and tried both EventHubTrigger and IoT Hub (EventHub) - JavaScript template. Here it is as follow : module.exports = function (context, IoTHubMessages) { context.log(JavaScript eventhub trigger function called for message array ${IoTHubMessages}); IoTHubMessages.forEach(message => { context.log(Processed message ${JSON.stringify(message)}); }); context.done(); };Akshat Desai
@Rita Han for binding in function json : { "bindings": [ { "type": "eventHubTrigger", "name": "IoTHubMessages", "direction": "in", "path": "iothub-ehub-HUBNAME-192805-73caa1654c", "connection": "HUBNAME_events_IOTHUB", "cardinality": "many", "consumerGroup": "myconsumer" } ], "disabled": false }Akshat Desai
Your binding information looks like correct. What about the locations of your IoT Hub and Azure Function?Rita Han
ya, Location for IoT Hub and Azure Function is different but i still get normal device message (not twin changes Events) as log, in azure function logs.Akshat Desai

2 Answers

1
votes

Your Routes setup is correct. I am guessing the problem is on the consumer side of the Azure IoT Hub events (default endpoint). You can use for test purpose a Device Explorer tool. The following screen snippet shows my example:

DeviceExplorer

other quick option to consume these events is creating a azure function

using System;

public static void Run(string myIoTHubMessage, TraceWriter log)
{
    log.Info($"C# IoT Hub trigger function processed a message: {myIoTHubMessage}");
}

function.json file:

{
  "bindings": [
    {
      "type": "eventHubTrigger",
      "name": "myIoTHubMessage",
      "direction": "in",
      "path": "myPath",
      "connection": "myevents_IOTHUB",
      "consumerGroup": "$Default",
      "cardinality": "many"
    }
  ],
  "disabled": true
 }
  • One more thing, you can press the button Run for testing a match. It should be shown Result:Match
0
votes

Finally, I got solution i just switch to another account and setup everything from scratch it is working perfectly fine.

The only difference i notice is location in my old account Location in WEST US and in new account in CENTRAL US. I don't find the exact solution but it's working for me. But i am still wondering is it location based issue or something else?