Registry / azure / azure-storage-blob

azure-storage-blob

JSON →
library12.30.0pypypi✓ verified 25d ago

Official Azure Blob Storage client library for Python. Current version: 12.28.0 (Mar 2026). v12 (released 2019) is a complete rewrite from v2.x — BlockBlobService removed, replaced by BlobServiceClient/ContainerClient/BlobClient. Most LLM training data and older tutorials use the removed v2 BlockBlobService API. Recommended auth is DefaultAzureCredential (azure-identity) not connection strings in production.

pip install azure-storage-blob
INSTALL
IMPORT
SIG · AZURE-STORAGE-BLOB
A
azure-storage-blob
azurepythonv12.30.0
Install
4.3s avg
Import
963ms
Disk
47MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v12.30.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 0.999s · 47.9MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 4.3s · import 0.926s · 48MB
47MB installed
● package 47MB
Code
Verified usage

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

BlobServiceClient
from azure.storage.blob import BlobServiceClient
from azure.storage.blob import BlobServiceClient
ContainerClient
from azure.storage.blob import ContainerClient
BlobClient
from azure.storage.blob import BlobClient

azure-storage-blob v12 with DefaultAzureCredential upload/download.

# pip install azure-storage-blob azure-identity from azure.identity import DefaultAzureCredential from azure.storage.blob import BlobServiceClient # Production: passwordless auth credential = DefaultAzureCredential() blob_service_client = BlobServiceClient( account_url='https://myaccount.blob.core.windows.net', credential=credential ) # Create container container_client = blob_service_client.create_container('mycontainer') # Upload from file blob_client = blob_service_client.get_blob_client( container='mycontainer', blob='sample.txt' ) with open('sample.txt', 'rb') as data: blob_client.upload_blob(data) # List blobs for blob in blob_service_client.get_container_client('mycontainer').list_blobs(): print(blob.name) # Download downloader = blob_client.download_blob() content = downloader.readall() print(content)
Debug
Known issues
breakingBlockBlobService removed in v12. Raises ImportError: 'cannot import name BlockBlobService'. This is the #1 error when using LLM-generated Azure storage code.
fix
from azure.storage.blob import BlobServiceClient — not BlockBlobService
affects: >= 12.0
breakingcreate_blob_from_path(), create_blob_from_text(), create_blob_from_stream(), get_blob_to_path(), get_blob_to_text() all removed in v12. Use upload_blob() and download_blob() instead.
fix
blob_client.upload_blob(data) and blob_client.download_blob().readall()
affects: >= 12.0
breakingSAS token generation moved from class method to standalone function in v12. Old: service.generate_account_shared_access_signature(). New: generate_account_sas() top-level function.
fix
from azure.storage.blob import generate_account_sas, ResourceTypes, AccountSasPermissions
affects: >= 12.0
gotchaupload_blob() raises ResourceExistsError if blob already exists. Default overwrite=False. Must pass overwrite=True to replace.
fix
blob_client.upload_blob(data, overwrite=True)
affects: all
gotchadownload_blob() returns a StorageStreamDownloader — not bytes directly. Must call .readall() or .read() to get content.
fix
content = blob_client.download_blob().readall()
affects: all
gotchaDefaultAzureCredential is recommended for production but relies on multiple underlying authentication methods (e.g., environment variables, Azure CLI, Managed Identity). It will raise a ClientAuthenticationError if none of these methods are configured or accessible in the execution environment.
fix
Ensure one of DefaultAzureCredential's underlying authentication methods is properly configured for your environment. This might involve setting environment variables (e.g., AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET), logging in via the Azure CLI (`az login`), or ensuring a Managed Identity is assigned and accessible to the resource running the code. Also, ensure 'azure-identity' is installed.
affects: all
gotchaAsync client requires separate import: from azure.storage.blob.aio import BlobServiceClient. Mixing sync and async clients causes TypeError.
fix
from azure.storage.blob.aio import BlobServiceClient for async usage.
affects: all
gotchaDefaultAzureCredential raises ClientAuthenticationError if it cannot find valid credentials in the execution environment. This often happens in non-Azure environments without Azure CLI logged in, or in Azure environments missing Managed Identity, environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET), or other configured credential sources.
fix
Ensure the execution environment has valid credentials configured for DefaultAzureCredential to discover. For local development, log in via Azure CLI (`az login`). For Azure deployments, use Managed Identity, set environment variables, or ensure a Workload Identity is properly configured. Install 'azure-identity-broker' for Visual Studio Code credential support.
affects: all
Upgrade
Version history
12.30.0latest on PyPI · released Jun 8, 2026
Audit
Dependencies
azure-corerequiredRequired. Installed automatically.
azure-identityoptionalRequired for DefaultAzureCredential / managed identity auth. Recommended for production.
Agent activity
92 hits · last 30 days
node
86
OpenAI (training)
1
Resources
azure-storage-blob — pip install azure-storage-blob · libregistry