2

For my IoT Hub backend solution, how can I register for notifications when

A) a reported property from a client is changed and

B) a desired property from "myself" has finally be updated (because the my updates are synchronous and I don't seem to be able to get a callback immedially from RegistryManager.UpdateTwinAsync().

My backend is a .NET Core web in C# and I'm using the Microsoft.Azure.Devices library.

Jon Th
  • 347
  • 2
  • 13

1 Answers1

0

See from here:

Receive twin notifications. This operation allows the solution back end to be notified when the twin is modified. To do so, your IoT solution needs to create a route and to set the Data Source equal to twinChangeEvents. By default, no such routes pre-exist, so no twin notifications are sent.

You can, for example, create a route into a Service Bus topic and read from there in your backend app using the Service Bus SDK.

silent
  • 14,494
  • 4
  • 46
  • 86
  • 1
    Thank you, but I find it next to impossible to figure out what library and function I should use to register to receive device twin notifications from routes, even though I can create a route. Like I said, my backend is a .NET Core web in C# and I'm using the Microsoft.Azure.Devices library. I already use the RegistryManager class in that library but I can´t find anything related to register for messages from routes or changes in reported device twin properties. Anyone? – Jon Th Nov 26 '19 at 16:39
  • As I wrote: create a route in IoT Hub to a certain endpoint, such as Service Bus or Event Hub. This endpoint is of IoT Hub, thus you cannot use the IoT Hub SDK to read from them. So, you can for example use the Service Bus SDK (=https://www.nuget.org/packages/Microsoft.Azure.ServiceBus/) to read from there – silent Nov 26 '19 at 16:41
  • Ok, thanks. Do you know which way is better - Service bus or Event hub to get reported device twin change notifications and which one is cheaper? – Jon Th Nov 27 '19 at 10:33
  • ...hmm, according to this, the Event hub sounds like the way to go for my situation: https://www.serverless360.com/blog/azure-event-hubs-vs-service-bus – Jon Th Nov 27 '19 at 10:50