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
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file azure_iot_hub_api-0.2.0.tar.gz
.
File metadata
- Download URL: azure_iot_hub_api-0.2.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cea3c76e5bdbfa6993c13265701cb7f131e54a55ee4867424b6605f34551be3 |
|
MD5 | 762a683cf0050ce3bf76d320da0098d0 |
|
BLAKE2b-256 | 2c850d03cfdd3e75d2f495dfc3cfe0e8d7056cee9fd48d03cfcbc0f677a9094b |
File details
Details for the file azure_iot_hub_api-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: azure_iot_hub_api-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3d9d3c6c6950a2991e9421fae46bd12d47b671c35e8e32320712d137bcb8fe4 |
|
MD5 | e62ad9b24b2f80fabee7c8b0216ef7c4 |
|
BLAKE2b-256 | 98217048742368e7332bd414902f9d98572c36f7c6c04616c2ee9e3ef4316d78 |