1
votes

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?

1
Since you get it from Service Bus Queue, you should be using BrokeredMessage class instead of EvenData. - Mikhail Shilkov
Well that was easy!! Thanks Mikhail, do you want to put it as an answer? - Code Junkie

1 Answers

1
votes

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.