This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.
We recently released a new version of the Python SDK. We’re working hard to improve the experience of our developers and we heard your feedback—the Python SDK is no longer a wrapper around C code, it’s native Python! For those of you who haven’t seen this yet, here’s a quick overview:
What is the v2 Python SDK?
It’s a newly designed, Python-native SDK for working with Azure IoT. If you’re already familiar with our Python SDK, then you know that our first version (v1) was a wrapper around our C SDK. Like anything, this approach had its pros and cons. On the upside, developers familiar with the C SDK could further expand to Python with no underlying functionality differences. However, since the SDK was not in native Python, the developmental ease typically associated with Python was certainly lacking. With this new design, the v2 SDK aims to provide a simplified, more natural experience for Python developers.
Why should you upgrade to v2?
Simply put, because the developer experience is so much better!
Whereas the installation process for v1 involved a series of steps and was highly dependent on your development configuration, setting up v2 is as easy as running a pip command. Additionally, the APIs look and feel what they are—Python native.
To briefly illustrate the new look and feel of the SDK, here's a couple examples of the implementation differences between v1 and v2:
First, for sending telemetry to your IoT Hub, you'd write the following in v1:
Whereas in v2, you can simplify with:
As an even more pronounced example, in v1 you’d write the following for receiving a message from your IoT Hub:
But in the newly designed v2 SDK, you write:
Extra perks with V2!
While v2 provides all the same support you’ve come to expect for getting your IoT devices up and running, it also has a few changes:
The Python v2 SDK:
- now has support for module clients! Just as you can use our SDK to connect devices, you can now use Python to connect Azure IoT Edge Hubs and Azure IoT Hubs as well.
- supports an asynchronous API, along with a blocking synchronous API for compatibility scenarios.
- allows you to directly upload to Azure blob storage!
- only supports the MQTT protocol to simplify the connection experience. To see how to use web sockets, check out this sample.
We’ve also recently released a new version (2.0.1) that includes support for cloud-to-device messaging and improves MQTT connection resiliency.
We’re excited to see what you build with our new and improved Python SDK!
As we continue to work on improving the experience for Python developers, we encourage you to provide feedback through our open source Github repository and stay tuned on Azure updates for any new IoT SDK announcements.