Azure Multi-API Storage Client Library for Python
The `azure-multiapi-storage` library provides a client for Microsoft Azure Storage services, allowing developers to target specific API versions for Blob, Queue, File Share, and Data Lake services. This is a meta-package that orchestrates the official `azure-storage-*` SDKs. The current stable version is 1.6.0, with frequent updates to support newer Azure Storage API versions and deprecate older ones.
Warnings
- breaking Each release of `azure-multiapi-storage` frequently removes support for older Azure Storage API versions. For example, version 1.7.0b1 removes several older API versions for blob, fileshare, filedatalake, and queue services. Relying on a specific older API version means you might encounter breaking changes upon upgrading the library.
- breaking Version 1.5.0 of `azure-multiapi-storage` completely removed all 'Track 1' (older) SDKs. If your application was using these older APIs indirectly through this library, an upgrade to 1.5.0 or later will cause import and runtime errors.
- gotcha Using `pip install --pre azure-multiapi-storage` to install preview/beta versions (e.g., `1.7.0b1`) can lead to very rapid and breaking API version changes between beta releases. New API versions are often introduced alongside the immediate removal of older ones in these pre-releases.
- gotcha The `azure-multiapi-storage` library does not automatically handle API version negotiation or fallback. You must explicitly specify the desired Azure Storage API version in your import statements (e.g., `from azure.multiapi.storage.v2022_11_02.blob import ...`). Failing to do so, or using direct imports like `from azure.storage.blob import ...`, will bypass the multi-api functionality.
Install
-
pip install azure-multiapi-storage
Imports
- BlobServiceClient
from azure.multiapi.storage.v2022_11_02.blob import BlobServiceClient
- QueueServiceClient
from azure.multiapi.storage.v2018_03_28.queue import QueueServiceClient
Quickstart
import os
from azure.multiapi.storage.v2022_11_02.blob import BlobServiceClient
connection_string = os.environ.get('AZURE_STORAGE_CONNECTION_STRING', 'DefaultEndpointsProtocol=https;AccountName=test;AccountKey=test;EndpointSuffix=core.windows.net')
if connection_string == 'DefaultEndpointsProtocol=https;AccountName=test;AccountKey=test;EndpointSuffix=core.windows.net':
print("WARNING: AZURE_STORAGE_CONNECTION_STRING not set. Using dummy connection string. This will likely fail.")
try:
# Create a BlobServiceClient with the specified API version
blob_service_client = BlobServiceClient.from_connection_string(connection_string)
# List containers (example operation)
print("Listing blob containers:")
for container in blob_service_client.list_containers(name_starts_with="my"): # Add name_starts_with for faster results if many containers
print(f"- {container['name']}")
except Exception as e:
print(f"An error occurred: {e}")
print("Ensure AZURE_STORAGE_CONNECTION_STRING is set and valid, and containers exist.")