Azure Multi-API Storage Client Library for Python

1.6.0 · active · verified Sat Apr 11

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

Install

Imports

Quickstart

This quickstart demonstrates how to initialize a `BlobServiceClient` using a specific API version (`v2022_11_02`) and list blob containers. Ensure you have the `AZURE_STORAGE_CONNECTION_STRING` environment variable set with your Azure Storage account connection string.

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.")

view raw JSON →