Skip to main content

Azure iot hub api with azure cli backend

Project description

azure-iot-hub-api

Azure IoT hub api interface using azure cli

This package is alternative to azure-iot-hub which hasn't had any updates in several years and relays on the deprecated azure-uamqp-python.

This package can be used as a stopgap until the azure-iot-hub been updated to no longer depend on deprecated packages.

Currently these very basic functionalities of the IoTHubRegistryManager are supported:

  • create_device_with_sas
  • get_twin
  • get_twins
  • update_twin
  • get_device
  • get_devices
  • delete_device

The package are designed, so that, if it is used as alternative to existing azure-iot-hub in the project, it need to make only little changes to the codebase.

Usage

Install package :

pip install azure-iot-hub-api

Simply import and create IoTHubRegistryManager using connection string, then you can call api functions.

Sample code

from azure_iot_hub_api import IoTHubRegistryManager

AZURE_IOT_CONNECTION_STRING = "HostName=MyAzureIotHub.azure-devices.net;SharedAccessKeyName=xxx;SharedAccessKey=xxxxxxxxxxxxxx"
registry_manager = IoTHubRegistryManager(AZURE_IOT_CONNECTION_STRING)
my_device_id = 'E-11'
primary_key = 'primary-base64-key'
secondary_key = 'secondary-base64-key'

# Create a device
registry_manager.create_device_with_sas(
        device_id=my_device_id,
        primary_key=primary_key,
        secondary_key=secondary_key,
        status='enabled',
    )

# Get device twin
my_device_twin = registry_manager.get_twin(device_id=my_device_id)
my_device_twin.properties.desired['speed'] = 70

# Update device twin (It updates only desired object)
registry_manager.update_twin(device_id=my_device_id, twin=my_device_twin)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azure_iot_hub_api-0.2.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

azure_iot_hub_api-0.2.2-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file azure_iot_hub_api-0.2.2.tar.gz.

File metadata

  • Download URL: azure_iot_hub_api-0.2.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for azure_iot_hub_api-0.2.2.tar.gz
Algorithm Hash digest
SHA256 67ffa7b16c4e14a5501455a2a3920753d63cb4def80b1718291ceb9783409c0c
MD5 94f6c21910481fe4dc93691a13e73631
BLAKE2b-256 a50afb9834b2ad5c22d0416b72b94b5a574466ed3438e9c26a47d0b06dcb6ba2

See more details on using hashes here.

File details

Details for the file azure_iot_hub_api-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for azure_iot_hub_api-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 827727481f84babe82167df804a8708343800888a7772e38d7ac5ac36777b9ef
MD5 8cdf6a39ee4635012080de1041f640af
BLAKE2b-256 11c354409dd2fd520e4f97c3dade1ed7339210ff595e99495da34c2ddba92fbc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page