1

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.

Nithin
  • 1,376
  • 12
  • 29
  • How do you receive these events? Can you show your code? – Rita Han Sep 14 '17 at 02:31
  • @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 Sep 14 '17 at 04:51
  • @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 Sep 14 '17 at 05:09
  • Your binding information looks like correct. What about the locations of your IoT Hub and Azure Function? – Rita Han Sep 14 '17 at 06:56
  • 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 Sep 14 '17 at 07:18
  • Yes, different locations are not the problem. I want to check if your issue related to specified location. Can you go to azure portal and check your route listed in iothub->Routes and its ENABLE property is true? – Rita Han Sep 15 '17 at 01:32
  • Yes, Routes property is already ENABLE-> True and i also tried both at same location(WEST US) but still not working – Akshat Desai Sep 15 '17 at 05:34

2 Answers2

1

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
Roman Kiss
  • 7,925
  • 1
  • 8
  • 21
  • I create azure function to consume Azure IoT Hub events (default endpoint) as you mentioned but i didn't get any twin update trigger, the only thing i get is iot-hub messages which i sent from device SDK. – Akshat Desai Sep 13 '17 at 13:36
  • I also test Routes functionality independently and in result of that i also got Result:Match – Akshat Desai Sep 13 '17 at 13:38
  • For update device twin i update desired value of device twin from iot-hub portal and also change reported value from device side SDK but for both ways no trigger occured. – Akshat Desai Sep 13 '17 at 13:47
  • do you have a proof of the communications between the device twin and cloud backend? You can use a tool such as https://iotdevtool.com/ or https://www.codeproject.com/Articles/1173356/Azure-IoT-Hub-Tester to simulate a MQTT Device with Azure IoT Hub. This test will proof that the device twin is updated. – Roman Kiss Sep 13 '17 at 14:56
  • 1
    also, you can use a Portal Monitoring/Metrics to see if your device twin has been updated from device and/or back end. – Roman Kiss Sep 13 '17 at 15:09
  • yes, device twin is updated properly from back end and i also verify device twin functionality working perfectly fine. – Akshat Desai Sep 14 '17 at 04:29
  • In this point: 1. the Routes setup is correct (Twin Change Events, events, On, true) - 2. AF is triggered only for device messages - 3. Using the tool you have a proof of the device twin updates at the both ends such as device and back end - 4. AF is not triggered from the TwinChangeEvents notification messages - 5. Portal Monitoring/Metrics shows that the device twin has been updated ---- So, I have one more bullet for this test case such as creating a Custom Endpoint (EventHub) for TwinChangeEvents messages – Roman Kiss Sep 14 '17 at 06:38
  • I tried custom EventHub and create new route for TwinChangeEvents with newly create custom EventHub and change according in AF but still no luck. – Akshat Desai Sep 15 '17 at 05:39
0

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?