A collection of utilities for interacting with Microsoft Azure Web Services
Project description
pyazureutils
pyazureutils is a collection of utilities for interacting with Microsoft Azure Web Services.
Usage
pyazureutils is intended as a library as well as a stand-alone CLI. Its primary consumer is iotprovision. The CLI requires that the Azure CLI ('az') is installed.
Command-line interface
pyazureutils CLI is invoked with one command, one action and optional switches. See help and examples below for more details.
Getting help:
pyazureutils --help
Getting command-specific help (iotcentral command):
pyazureutils iotcentral --help
iotcentral command
The iotcentral command supports device registration with Azure IoT Central
Example:
pyazureutils iotcentral register-device
Device registration can optionally include the switches:
--application-name <application name to register with>
--display-name <display name to use for the device registration>
--certificate-file <certificate to use for registration, if not read from a kit>
Library
pyazureutils can be used as a library by instantiating any of the contained classes.
For example to perform provisioning for Azure IoT:
# pyazureutils uses the Python logging module
import logging
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
# The target must be running provisioning firmware, pykitcommander is used to accomplish this.
# It locates the bundled firmware for the function requested, programs it onto the MCU on the kit
# and returns a protocol object and port for communicating with the application
from pykitcommander.kitprotocols import get_protocol
protocol, port = get_protocol("iotprovision-azure")
# Instantiate the provisioner
from pyazureutils.custom_provision import AzureCustomProvisioner
provider_provisioner = AzureCustomProvisioner("my_signer_ca_key_file",
"my_signer_ca_cert_file",
"generated_device_csr_file",
"generated_device_cert_file")
# Do the actual provisioning
device_id = provider_provisioner.provision(protocol, port)
The above example will generate a device certificate and save it along with the CA signer certificate in WINC flash. Generated certificates and Device ID are saved to files as well.
Logging
This package uses the Python logging module for publishing log messages to library users.
A basic configuration can be used (see example), but for best results a more thorough configuration is recommended in order to control the verbosity of output from dependencies in the stack which also use logging.
Dependencies
This package uses pyedbglib through other libraries for USB communications. For more information see: https://pypi.org/project/pyedbglib/.
Versioning
pyazureutils version can be determined by:
from pyazureutils.version import VERSION as pyazureutils_version
print("pyazureutils version {}".format(pyazureutils_version))
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 Distributions
Built Distribution
Hashes for pyazureutils-0.6.3.15-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06ac09a01370789c8ef2b370538f1a927281381d7432efa658abd13eb8b428b9 |
|
MD5 | 30c8685226139c7d41dc165cf8744b14 |
|
BLAKE2b-256 | 69196041c96e47099dc88574fe339f29cf91e74af59e4d45894b7782325a2e10 |