Take back control over IoTHub messages in Azure Functions

Azure Functions are a blessing for IoT solutions. To be so flexible executing code whenever messages are arriving, every IoT project is fully depending on it.

But one of the biggest frustrations is the casting of (EventHub) messages towards a string! Only the message body is left! Once a message is passed on to an Azure Function, I only have access to the body of the message. I can not access the (routing) properties anymore.

And before we got Azure Functions, we had to work with Stream Analytics. And I still do! And it’s so nice to have access to the IoT Hub values like the device name of the message. Because I am working with Azure Functions, I have to put it in the Message body first???

It would be great to have access to both the properties and the IoTHub values!

Finally, we are no longer dependent on the IoTHub routing is we want to know which message properties are accompanying the message. And we have all the tools in our hands to access the device name (and other goodies) in the system properties.

Bonus: Execution context

Did you ever wonder about the execution context of Azure functions? Maybe you are also confused like me when the logging text from multiple messages cross each other?

Now you can fix this. Just add this extra “ExecutionContext” parameter to the Azure Function:

Share this:

Vind ik leuk:

Gerelateerd

Gepubliceerd door Sander van de Velde

I started as an IT consultant in 1993. I like to get my hands dirty with software innovations and I try to implement these in my daily work.
Currently, I am involved in the IoT Platform part of Azure (eg. IoTHubs, StreamAnalytics, Azure Functions, Mobile Apps, EventHubs, Universal Apps) and Azure in general.
I've been presented with the 2017 Microsoft Most Valuable Professional (MVP) Award and I'm a member of the Microsoft Azure Advisory Board.
For me, it is important to share knowledge. And I am committed doing so by writing blogs, articles for magazines and giving lots of presentations.
When offline, I like cutting down trees using Gränsfors Bruks axes, sailing, motorcycling or geocaching with my wife and my sons.
Bekijk alle berichten van Sander van de Velde