Registry / azure / azure
library5.0.0pypypi✓ verified 22d ago

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.

pip install azure==4.0.0
INSTALL
IMPORT
SIG · AZURE
A
azure
azurepythonv5.0.0
Install
13.7s avg
Import
956ms
Disk
306MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.0.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 1.004s · 296.8MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 13.7s · import 0.908s · 297MB
306MB installed
● package 306MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BlobServiceClient
from azure.storage.blob import BlobServiceClient
from azure.storage import BlobServiceClient
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.
DefaultAzureCredential
from azure.identity import DefaultAzureCredential
from azure.common.credentials import ServicePrincipalCredentials
DefaultAzureCredential is the recommended, passwordless authentication method, replacing older credential types found in msrestazure or azure.common.

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

import os from azure.identity import DefaultAzureCredential from azure.storage.blob import BlobServiceClient # Replace with your storage account name or retrieve from environment variables STORAGE_ACCOUNT_NAME = os.environ.get('AZURE_STORAGE_ACCOUNT_NAME', 'yourstorageaccountname') CONTAINER_NAME = 'my-container' BLOB_NAME = 'hello_world.txt' try: # Authenticate using DefaultAzureCredential (recommended passwordless approach) credential = DefaultAzureCredential() # Construct the blob service client blob_service_client = BlobServiceClient(account_url=f"https://{STORAGE_ACCOUNT_NAME}.blob.core.windows.net/", credential=credential) # Get a client to interact with a specific container container_client = blob_service_client.get_container_client(CONTAINER_NAME) # Create the container if it doesn't exist try: container_client.create_container() print(f"Container '{CONTAINER_NAME}' created.") except Exception as e: if "ContainerAlreadyExists" in str(e): # Specific exception for idempotent create print(f"Container '{CONTAINER_NAME}' already exists.") else: raise # Upload data to a blob data = "Hello, Azure Blob Storage! This is a test blob." blob_client = container_client.get_blob_client(BLOB_NAME) blob_client.upload_blob(data, overwrite=True) print(f"Blob '{BLOB_NAME}' uploaded to container '{CONTAINER_NAME}'.") # Download the blob data downloaded_blob = blob_client.download_blob().readall() print(f"Downloaded blob content: {downloaded_blob.decode('utf-8')}") # Clean up (optional: delete the blob and container) # blob_client.delete_blob() # print(f"Blob '{BLOB_NAME}' deleted.") # container_client.delete_container() # print(f"Container '{CONTAINER_NAME}' deleted.") except Exception as ex: print(f"An error occurred: {ex}")
Debug
Known issues
breakingThe `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.
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.
affects: >=5.0.0
breakingMajor 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`).
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`).
affects: All versions migrating from pre-2019 SDKs
gotchaAuthentication should leverage `DefaultAzureCredential` from `azure-identity` for passwordless connections. Using account keys or hardcoding credentials is less secure and not recommended for production.
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.
affects: All versions
gotchaMany 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.
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`).
affects: All async-enabled versions
gotchaWhen 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.
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.
affects: All management client versions
breakingThe `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.
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.
affects: azure-core >= 1.38.0
Upgrade
Version history
5.0.0latest on PyPI · released Apr 8, 2020
Audit
Dependencies
azure-storage-bloboptionalExample client library for Blob Storage
azure-identityoptionalCore library for modern Azure authentication
azure-corerequiredFundamental shared components for all new Azure SDK libraries
Agent activity
44 hits · last 30 days
node
36
OpenAI (training)
2
Resources
azure — pip install azure · libregistry