{"id":3419,"library":"azure","title":"Microsoft Azure Client Libraries for Python (Meta-package)","description":"The `azure` package is a meta-package that historically bundled a wide range of Microsoft Azure client and management libraries for Python. As of version 5.0.0, this meta-package is officially deprecated. Users are strongly advised to install individual service-specific packages (e.g., `azure-storage-blob`, `azure-identity`, `azure-mgmt-compute`) based on their needs, rather than the monolithic `azure` package. The individual Azure SDK for Python client libraries follow a continuous release cadence, with updates often monthly for various services, while adhering to common Azure SDK design guidelines for consistency.","status":"deprecated","version":"5.0.0","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["cloud","azure","microsoft","sdk","client","management","storage","identity","deprecated"],"install":[{"cmd":"pip install azure==4.0.0","lang":"bash","label":"To install the last non-deprecated version (older applications)"},{"cmd":"pip install azure-storage-blob azure-identity","lang":"bash","label":"Recommended: Install specific client libraries (e.g., for Blob Storage and Identity)"}],"dependencies":[{"reason":"Example client library for Blob Storage","package":"azure-storage-blob","optional":true},{"reason":"Core library for modern Azure authentication","package":"azure-identity","optional":true},{"reason":"Fundamental shared components for all new Azure SDK libraries","package":"azure-core","optional":false}],"imports":[{"note":"Modern Azure SDKs import specific client objects directly from their service-specific sub-packages, not from a generic 'azure.storage' which might be from older SDKs or not exist.","wrong":"from azure.storage import BlobServiceClient","symbol":"BlobServiceClient","correct":"from azure.storage.blob import BlobServiceClient"},{"note":"DefaultAzureCredential is the recommended, passwordless authentication method, replacing older credential types found in msrestazure or azure.common.","wrong":"from azure.common.credentials import ServicePrincipalCredentials","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.storage.blob import BlobServiceClient\n\n# Replace with your storage account name or retrieve from environment variables\nSTORAGE_ACCOUNT_NAME = os.environ.get('AZURE_STORAGE_ACCOUNT_NAME', 'yourstorageaccountname')\nCONTAINER_NAME = 'my-container'\nBLOB_NAME = 'hello_world.txt'\n\ntry:\n    # Authenticate using DefaultAzureCredential (recommended passwordless approach)\n    credential = DefaultAzureCredential()\n    \n    # Construct the blob service client\n    blob_service_client = BlobServiceClient(account_url=f\"https://{STORAGE_ACCOUNT_NAME}.blob.core.windows.net/\", credential=credential)\n\n    # Get a client to interact with a specific container\n    container_client = blob_service_client.get_container_client(CONTAINER_NAME)\n    \n    # Create the container if it doesn't exist\n    try:\n        container_client.create_container()\n        print(f\"Container '{CONTAINER_NAME}' created.\")\n    except Exception as e:\n        if \"ContainerAlreadyExists\" in str(e): # Specific exception for idempotent create\n            print(f\"Container '{CONTAINER_NAME}' already exists.\")\n        else:\n            raise\n\n    # Upload data to a blob\n    data = \"Hello, Azure Blob Storage! This is a test blob.\"\n    blob_client = container_client.get_blob_client(BLOB_NAME)\n    blob_client.upload_blob(data, overwrite=True)\n    print(f\"Blob '{BLOB_NAME}' uploaded to container '{CONTAINER_NAME}'.\")\n\n    # Download the blob data\n    downloaded_blob = blob_client.download_blob().readall()\n    print(f\"Downloaded blob content: {downloaded_blob.decode('utf-8')}\")\n\n    # Clean up (optional: delete the blob and container)\n    # blob_client.delete_blob()\n    # print(f\"Blob '{BLOB_NAME}' deleted.\")\n    # container_client.delete_container()\n    # print(f\"Container '{CONTAINER_NAME}' deleted.\")\n\nexcept Exception as ex:\n    print(f\"An error occurred: {ex}\")\n\n","lang":"python","description":"This quickstart demonstrates how to connect to Azure Blob Storage using the recommended `DefaultAzureCredential` for authentication and perform basic operations like creating a container, uploading a blob, and downloading its content. It requires the `azure-storage-blob` and `azure-identity` packages. Ensure you have an Azure Storage Account and have configured `DefaultAzureCredential` (e.g., by logging in via Azure CLI: `az login` or setting environment variables like `AZURE_STORAGE_ACCOUNT_NAME`)."},"warnings":[{"fix":"Instead of `pip install azure`, install specific client libraries for each Azure service you need (e.g., `pip install azure-storage-blob azure-identity`). This reduces install size and improves dependency management.","message":"The `azure` meta-package (version 5.0.0 and above) is deprecated. Installing it will not provide the latest SDK versions for individual services and is highly discouraged.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Refer to official migration guides when upgrading existing codebases. Key changes include using `DefaultAzureCredential` for authentication and importing client objects directly from service-specific packages (e.g., `azure.storage.blob` instead of older `azure.storage`).","message":"Major architectural changes occurred between older Azure SDKs (often referred to as 'Track 1' or 'v2') and the current generation ('Track 2' or 'v3'). This involved significant changes to package names, class structures, and authentication patterns (e.g., moving from `msrestazure` to `azure-identity`).","severity":"breaking","affected_versions":"All versions migrating from pre-2019 SDKs"},{"fix":"Install `azure-identity` and use `DefaultAzureCredential()` which automatically tries various authentication methods (environment variables, Azure CLI, managed identity, etc.). Ensure your environment is configured for one of these methods.","message":"Authentication should leverage `DefaultAzureCredential` from `azure-identity` for passwordless connections. Using account keys or hardcoding credentials is less secure and not recommended for production.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For asynchronous operations, install an async transport like `aiohttp` (often via `pip install azure-storage-blob[aio]`) and use the `_aio` suffixed clients/modules (e.g., `BlobServiceClient.from_connection_string(**args, transport=AioHttpTransport())` or directly `from azure.storage.blob.aio import BlobServiceClient`).","message":"Many Azure client libraries offer both synchronous (default) and asynchronous (`.aio` suffixed packages/modules) APIs. Mixing them or failing to use an async transport can lead to errors or suboptimal performance.","severity":"gotcha","affected_versions":"All async-enabled versions"},{"fix":"For PUT operations, it's generally safer to first `get` the existing resource, modify only the desired fields, and then call `create_or_update` with the modified object. This ensures fields not explicitly set are preserved.","message":"When using Azure management clients (`azure-mgmt-*`), setting a field to `None` in an update (PUT) operation might interpret `None` as a request to *delete* that field, rather than keeping its existing value.","severity":"gotcha","affected_versions":"All management client versions"},{"fix":"Ensure all client libraries in your application are updated to compatible versions. If you store continuation tokens, they may need to be re-generated with the new SDK version. Update all `azure-*` packages to their latest stable releases to minimize compatibility issues.","message":"The `azure-core` library (a foundational dependency for most Azure SDKs) changed its continuation token format in version 1.38.0. This can break pagination and long-running operations if tokens generated by older versions are used with newer clients or vice-versa.","severity":"breaking","affected_versions":"azure-core >= 1.38.0"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}