The Azure IoT Device SDK for Python enables Python developers to easily create IoT device solutions that seamlessly connect to the Azure IoT Hub ecosystem.
-
If you're migrating v2.x.x code to use v3.x.x check the IoT Hub Migration Guide and/or the Provisioning Migration Guide
-
If you're looking for the v2.x.x client library, it is now preserved in the v2 branch
-
If you're looking for the v1.x.x client library, it is now preserved in the v1-deprecated branch.
-
If you're looking for the azure-iot-hub library, it is now located in the azure-iot-hub-python repository
NOTE: 3.x.x is still in beta and APIs are subject to change until the release of 3.0.0
Installing the library
The Azure IoT Device library is available on PyPI:
pip install azure-iot-device==3.0.0b2
Python 3.7 or higher is required in order to use the library
Using the library
You can view the samples directory to see examples of SDK usage.
Full API documentation for this package is available via Microsoft Docs. Note that this documentation may currently be out of date as v3.x.x is still in preview at the time of this writing.
You can use the Connection Diagnostic Tool to help ascertain the cause of any connection issues you run into when using the SDK.
Features
*Features that are not planned may be prioritized in a future release, but are not currently planned
This library primarily uses the MQTT protocol.
IoTHubSession
Features | Status | Description |
---|---|---|
Authentication | Connect your device to IoT Hub securely with supported authentication, including symmetric key, X-509 Self Signed, Certificate Authority (CA) Signed, and SASToken | |
Send device-to-cloud message | Send device-to-cloud messages (max 256KB) to IoT Hub with the option to add custom properties. | |
Receive cloud-to-device messages | Receive cloud-to-device messages and read associated custom and system properties from IoT Hub. | |
Device Twins | IoT Hub persists a device twin for each device that you connect to IoT Hub. The device can perform operations like get twin tags, subscribe to desired properties. | |
Direct Methods | IoT Hub gives you the ability to invoke direct methods on devices from the cloud. The SDK supports handler for method specific and generic operation. | |
Connection Status and Error reporting | Error reporting for IoT Hub supported error code. | |
Connection Retry | Dropped connections will be retried with a fixed 10 second interval by default. This functionality can be disabled if desired, and the interval can be configured | |
Upload file to Blob | A device can initiate a file upload and notifies IoT Hub when the upload is complete. | |
Direct Invocation of Method on Modules | Invoke method calls to another module using using the Edge Gateway. |
ProvisioningSession
Features | Status | Description |
---|---|---|
TPM Individual Enrollment | Provisioning via Trusted Platform Module. | |
X.509 Individual Enrollment | Provisioning via X.509 root certificate. Please review the samples folder and this quickstart on how to create a device client. | |
X.509 Enrollment Group | Provisioning via X.509 leaf certificate. Please review the samples folder on how to create a device client. | |
Symmetric Key Enrollment | Provisioning via Symmetric key attestation. Please review the samples folder on how to create a device client. |
Support
The Azure IoT Hub Device Client supported releases is outlined in the following table.
Refer to the Azure IoT Device SDK lifecycle and support for details on the different supported stages.
Release | Category | End-of-life |
---|---|---|
2.12.0 | Active | - |
3.0.0b2 | Preview | 2023-7-15 |
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.