IoT Storage Client Library for Python
Project description
iot-storage-client
This package is a wrapper around the azure-storage-blob SDK to provide an asynchronous and synchronous client for interacting with Azure storage accounts in the cloud and on the edge.
Official Documentation (async version) | Source code | Package PyPI
Table of Contents
Versioning
This repository adheres to Semantic Versioning. It will be maintained through the CHANGELOG.md
and in GitHub Releases. It's important to note that you must maintain the version with your releases in iot/storage/client/_version.py
, otherwise a new package version will fail to get published.
Getting Started
This section provides basic examples with the iot-storage-client
.
Prerequisites
-
Python 3.7 or later is required to use this package.
-
You must have an Azure subscription and Azure storage account to use this package.
Basic Examples
-
Install via pip:
pip install iot-storage-client
-
Import and say hello:
from iot.storage.client import __version__ print(f"hello world from iot-storage-client version: {__version__}")
-
Basic usage:
import tempfile from iot.storage.client import CredentialType, LocationType, IoTStorageClient # instantiate client storage_client = IoTStorageClient( credential_type=CredentialType.ACCOUNT_KEY, location_type=LocationType.CLOUD_BASED, account_name="myAzBlobStorageAcctName", credential="myBlobPrimaryKey***" ) # print info w/ repr print(f"{storage_client.__repr__()}") # download blob to tempfile temp_file = tempfile.NamedTemporaryFile() download_result = storage_client.download_file( container_name="myAzBlobContainerName", source="path/to/blob.txt", dest=temp_file.name, ) if not download_result: print("unable to download file") temp_file.close() raise # upload tempfile to blob upload_result = storage_client.upload_file( container_name="myAzBlobContainerName", source=temp_file.name, dest="path/to/new/blob.txt", ) if not upload_result: print("unable to upload file") temp_file.close() raise # clean-up local memory temp_file.close()
-
Basic async usage:
import tempfile from iot.storage.client import CredentialType, LocationType, IoTStorageClientAsync # instantiate client storage_client = IoTStorageClientAsync( credential_type=CredentialType.ACCOUNT_KEY, location_type=LocationType.CLOUD_BASED, account_name="myAzBlobStorageAcctName", credential="myBlobPrimaryKey***" ) # print info w/ repr print(f"{storage_client.__repr__()}") # download blob to tempfile temp_file = tempfile.NamedTemporaryFile() download_result = await storage_client.download_file( container_name="myAzBlobContainerName", source="path/to/blob.txt", dest=temp_file.name, ) if not download_result: print("unable to download file") temp_file.close() raise # upload tempfile to blob upload_result = await storage_client.upload_file( container_name="myAzBlobContainerName", source=temp_file.name, dest="path/to/new/blob.txt", ) if not upload_result: print("unable to upload file") temp_file.close() raise # clean-up local memory temp_file.close()
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
Hashes for iot_storage_client-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d684d8f6e8a7e26a69f503e6f9af69f72e2937a46891c03e3e1052a06ba63d36 |
|
MD5 | d2aa19f2c1e5f52753fa5511dd969e9c |
|
BLAKE2b-256 | 1bb67522dac5240e2730c1ffec5ef043d87efd634da3deebd5064eb88f01e8fa |