I'm trying to receive notifications in the cloud back-end when Device twin properties change. To do this I have set up a route as seen in the picture link below
https://i.sstatic.net/sKNOG.jpg
I have also created an Azure Function that triggers on the default consumer group for the built in end-point events. But when I update the device twin document for one of my device the azure functions does not trigger. And if I monitor the events for the device using iothubexplorer or Device explorer I see no "updateTwin" events at all. However it works if I send regular device-to-cloud from the device I receive those.
Im using the following code to update the device twin:
'use strict';
var Client = require('azure-iot-device').Client;
var Protocol = require('azure-iot-device-mqtt').Mqtt;
var connectionString = '';
var client = Client.fromConnectionString(connectionString, Protocol);
client.open(function(err) {
if (err) {
console.error('could not open IotHub client');
} else {
console.log('client opened');
client.getTwin(function(err, twin) {
if (err) {
console.error('could not get twin');
} else {
var body = {
temperature: '40'
}
console.log(twin.properties.reported);
twin.properties.reported.update(body, function(err) {
if (err) {
console.error('could not update twin');
} else {
console.log('twin state reported');
process.exit();
}
});
}
});
}
});
Ive also tried using iothub-explorer using the following command: iothub-explorer update-twin InitialDevice {\"properties\":{\"desired\": {\"interval\":9000}}} --login ""
I tested with the code in your post, it works, so your Routes setup and code are correct.
Have you referred to this topic? I guess the problem is similar with that.Please try to check the account location and test with Roman Kiss's suggestion.