Communicating with Azure IoT using Python

During last Christmas' project (the Poor Man's IoT - read more about it here and here) I wanted to build a small Proof of Concept communicating my home freezer sensor to Azure IoT. However, if you're not a C# dev, the steps to set up this 'small' Proof of Concept can be quite daunting - especially if you're a data dude used to languages like Python.

"Just" building an easy Field Gateway using some online C# samples required me to install Visual Studio 2015 (as a data guy, all I had was SSDT and SSDT-BI, which is technically Visual Studio but not enough to build a Field Gateway), download the Azure SDK, and some more libraries. Around 7 GB of downloads and several hours later, my laptop was stuffed with awesome libraries I didn't need, but q.e.d.: it's cheap and kinda easy (conceptually speaking, or if you code C# on a regular basis) to set up your own IoT proof-of-concept.

Still, what I really wanted was communicating with Azure IoT using my Python prototype application. After all, that was the code I1 could test on any laptop, (Android) phone, Raspberry/Banana/Orange Pi, etc.

So. I spent some time figuring out how to do exactly that, stumbled upon an incredibly useful library from Štěpán Bechynský (@stepanb) on Github2, forked & altered the code a small bit for my own Sensor Hub, and started writing a blogpost.

Then, reality kicked in. When I did my first commit (on March 27th) I already was 11 days late, for the "official" Azure IoT samples on GitHub were updated ... with a Python client.

So, two lessons for me personally:

  1. If you don't have a library, you can always use the web API (which is what @stepanb's library does)
  2. Double-check your itch before scratching it, you stupid. Pretty sure the release cycle of those awesome Azure devs is waaaaay faster than yours3

Still, if you'd like to see my code - it's out there at I'll soon update it to let my Python code use the "official" Python client.

Founder of this blog. Business Intelligence consultant, developer, coach, trainer and speaker at events. Currently working at Dura Vermeer. Loves to explain things, providing insight in complex issues. Watches the ongoing development of the Microsoft Business Intelligence stack closely. Keeping an eye on Big Data, Data Science and IoT.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Next ArticleMoving BI to the Cloud: Ditch SSAS?