1

I have setup routing to a Service Bus Queue using Azure IoT Hub. I followed this tutorial to get it working: https://azure.microsoft.com/en-gb/blog/how-to-use-azure-functions-with-iot-hub-message-routing/.

In my function I am trying to get the DeviceId so that I can verify the device that the message came from. I have a string parameter called message which receives The message I have sent. However, I need to get the DeviceId from the message. I tried to change the type to EventData but I got a serialisation error because of the JSON message type I think.

I will update this post with the actual code and error message tomorrow but wondered if anyone had come across this issue?

Code Junkie
  • 519
  • 2
  • 7
  • 16

1 Answers1

1

Since you get it from Service Bus Queue, you should be using BrokeredMessage class instead of EvenData.

You should be able to extract Device Id from it.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107