Search code examples
pythonazureazure-iot-hubpypi

Alternatives for azure-iot-hub python package


The azure-iot-hub python package hasn't had any updates in last 2 years, and depends on deprecated azure-uamqp-python that is failing to build on systems such as Mac ARM and Linux ARM on Python 3.12+.

So, is there any alternative to replace it?

Reference: https://github.com/ansible-collections/azure/pull/1512

Edited: Currently I have no problem with that. I am looking for an alternative in case of possible removing of this package from Ansible collection.


Solution

  • The steps below outline how to set up Azure IoT Hub and manage devices using Azure CLI commands:

    • To log into your Azure account, use the Azure CLI and execute the following command:
    az login
    

    Enter Image Description Here

    • Create IoT Hub: If you haven't created an IoT Hub yet, you can create one using the Azure CLI:
    az iot hub create --name <hub_name> --resource-group <resource_group_name> --sku S1
    

    Enter Image Description Here

    • Refer to this documentation to create, list, update, and delete devices using Azure CLI.

    Create Device:

    az iot hub device-identity create --hub-name <hub_name> --device-id <device_id>
    

    Enter Image Description Here

    List Devices:

    az iot hub device-identity list --hub-name <hub_name>
    

    Enter Image Description Here

    • Get Device Twin:
    az iot hub device-twin show --device-id <device_id> --hub-name <hub_name>
    

    Enter Image Description Here

    • refer this documentation to get and update device twin properties using Azure CLI.

    • Update Device Twin:

    az iot hub device-twin update --device-id
                                  [--add]
                                  [--auth-type {key, login}]
                                  [--desired]
                                  [--etag]
                                  [--force-string]
                                  [--hub-name]
                                  [--login]
                                  [--remove]
                                  [--resource-group]
                                  [--set]
                                  [--tags]
    

    Enter Image Description Here

    Enter Image Description Here

    • Refer this SO to How to run Azure CLI commands using python