{"id":5585,"library":"azure-storage","title":"Azure Storage SDK (Legacy)","description":"This is the legacy Microsoft Azure Storage SDK for Python, currently at version 0.37.0. This package unified clients for Blobs, Queues, and Files. It is superseded by the modular, actively developed client libraries (`azure-storage-blob`, `azure-storage-queue`, `azure-storage-file-share`) which offer a more modern API, better async support, and integration with Azure Identity. This package is no longer actively maintained.","status":"deprecated","version":"0.37.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/storage/azure-storage","tags":["azure","cloud","storage","blob","queue","file","deprecated"],"install":[{"cmd":"pip install azure-storage","lang":"bash","label":"Install legacy package"},{"cmd":"pip install azure-storage-blob azure-storage-queue azure-storage-file-share","lang":"bash","label":"Install recommended modern packages"}],"dependencies":[],"imports":[{"note":"BlockBlobService is from the legacy package; BlobServiceClient is the modern equivalent but from a different package (`azure-storage-blob`). Do not mix them or assume direct compatibility.","wrong":"from azure.storage.blob import BlobServiceClient","symbol":"BlockBlobService","correct":"from azure.storage.blob.baseblobservice import BaseBlobService\n# Note: This is for the legacy azure-storage package (v0.x).\n# For new development, use BlobServiceClient from azure-storage-blob (v12.x+)."},{"note":"BlobServiceClient is part of the modern `azure-storage-blob` package, not the legacy `azure-storage` package (v0.x).","wrong":"from azure.storage import BlobServiceClient","symbol":"BlobServiceClient","correct":"from azure.storage.blob import BlobServiceClient"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.storage.blob import BlobServiceClient\n\n# Recommended: Use the modern azure-storage-blob package\n# Ensure AZURE_STORAGE_CONNECTION_STRING or AZURE_STORAGE_ACCOUNT_NAME is set\n# Or configure Azure Identity credentials for DefaultAzureCredential\n\ntry:\n    # Option 1: Using connection string (simpler for quickstart)\n    connection_string = os.environ.get('AZURE_STORAGE_CONNECTION_STRING')\n    if connection_string:\n        blob_service_client = BlobServiceClient.from_connection_string(connection_string)\n    else:\n        # Option 2: Using DefaultAzureCredential (recommended for production)\n        account_url = os.environ.get('AZURE_STORAGE_ACCOUNT_URL', 'https://<your_account_name>.blob.core.windows.net')\n        if not account_url.startswith('https://') and 'AZURE_STORAGE_ACCOUNT_NAME' in os.environ:\n            account_name = os.environ['AZURE_STORAGE_ACCOUNT_NAME']\n            account_url = f'https://{account_name}.blob.core.windows.net'\n\n        credential = DefaultAzureCredential()\n        blob_service_client = BlobServiceClient(account_url, credential=credential)\n\n    container_name = 'mytestcontainer'\n    blob_name = 'mytestblob.txt'\n    local_file_name = 'sample.txt'\n    data = 'Hello, Azure Blob Storage!'\n\n    print(f\"Creating container: {container_name}\")\n    container_client = blob_service_client.get_container_client(container_name)\n    try:\n        container_client.create_container()\n    except Exception as e:\n        if 'ContainerAlreadyExists' not in str(e):\n            raise\n        print(f\"Container '{container_name}' already exists.\")\n\n    with open(local_file_name, 'w') as file:\n        file.write(data)\n\n    print(f\"Uploading blob: {blob_name}\")\n    with open(local_file_name, 'rb') as data_file:\n        container_client.upload_blob(name=blob_name, data=data_file, overwrite=True)\n\n    print(f\"Listing blobs in '{container_name}':\")\n    for blob in container_client.list_blobs():\n        print(f\" - {blob.name}\")\n\n    print(f\"Downloading blob: {blob_name}\")\n    download_blob_client = container_client.get_blob_client(blob_name)\n    download_data = download_blob_client.download_blob().readall()\n    print(f\"Downloaded content: {download_data.decode('utf-8')}\")\n\n    # Clean up\n    # print(f\"Deleting blob: {blob_name}\")\n    # container_client.delete_blob(blob_name)\n    # print(f\"Deleting container: {container_name}\")\n    # container_client.delete_container()\n\nexcept Exception as ex:\n    print(f\"Error: {ex}\")\n    print(\"Please ensure environment variables (AZURE_STORAGE_CONNECTION_STRING or AZURE_STORAGE_ACCOUNT_URL/NAME and Azure Identity vars) are set correctly.\")\n","lang":"python","description":"This quickstart demonstrates how to use the *modern* `azure-storage-blob` library (v12.x+) for interacting with Azure Blob Storage. This is the recommended approach for all new development. It shows container creation, blob upload, listing, and download using either a connection string or `DefaultAzureCredential` for authentication. Remember to install `azure-storage-blob` and `azure-identity`."},"warnings":[{"fix":"Migrate to `azure-storage-blob` (for blobs), `azure-storage-queue` (for queues), and `azure-storage-file-share` (for files). Review Microsoft's migration guides for detailed instructions.","message":"The `azure-storage` package (v0.x) has been entirely superseded by the modular client libraries (`azure-storage-blob`, `azure-storage-queue`, `azure-storage-file-share`, all v12.x+). There is no direct upgrade path; code written for `azure-storage` will require a complete rewrite to use the new client libraries due to different class names, API signatures, and object models.","severity":"breaking","affected_versions":"0.1.0 - 0.37.0"},{"fix":"Always use the modern, modular Azure Storage SDKs (e.g., `azure-storage-blob` v12.x+) for new development. For existing projects, plan a migration to the newer libraries.","message":"The `azure-storage` package itself is deprecated and no longer receives active development or new features. Using it for new projects is strongly discouraged.","severity":"deprecated","affected_versions":"0.1.0 - 0.37.0"},{"fix":"Familiarize yourself with the authentication mechanisms of the modern SDKs, prioritizing `DefaultAzureCredential` for production environments and connection strings for development ease. Install `azure-identity` for credential management.","message":"Authentication methods and client initialization patterns are completely different between the legacy `azure-storage` (v0.x) and the modern modular SDKs (v12.x+). The modern SDKs leverage `azure-identity` for robust, token-based authentication (e.g., `DefaultAzureCredential`), alongside connection strings or SAS tokens.","severity":"gotcha","affected_versions":"All versions of `azure-storage` (v0.x) vs `azure-storage-blob` (v12.x+)"},{"fix":"Refer to the official documentation for the modern `azure-storage-blob` (or `queue`, `file-share`) packages to understand the new API structure and client hierarchy.","message":"The Python Azure SDK underwent a complete redesign in its V2 efforts, resulting in entirely new client classes and method names. For instance, `BlockBlobService` from `azure-storage` is replaced by `BlobServiceClient`, `ContainerClient`, and `BlobClient` in `azure-storage-blob`.","severity":"gotcha","affected_versions":"All versions of `azure-storage` (v0.x) vs `azure-storage-blob` (v12.x+)"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}