OverviewHistoryStatsSecurity
npx skills add ...
Documentation
SKILL.md
npx skills add microsoft/skills --skill azure-storage-blob-py
Azure Blob Storage SDK for Python. Use for uploading, downloading, listing blobs, managing containers, and blob lifecycle. Triggers: "blob storage", "BlobServiceClient", "ContainerClient", "BlobClient", "upload blob", "download blob".
npx skills add microsoft/skills --skill azure-storage-blob-py
Client library for Azure Blob Storage — object storage for unstructured data.
🔑 Two rules apply to every code sample below:
- Prefer
DefaultAzureCredential. It works locally (Azure CLI / VS Code / Developer CLI) and in Azure (managed identity, workload identity) with no code change. Avoid connection strings, account/API keys — they bypass Entra audit and rotation.
- Local dev:
DefaultAzureCredentialworks as-is.- Production: set
AZURE_TOKEN_CREDENTIALS=prod(orAZURE_TOKEN_CREDENTIALS=<specific_credential>) to constrain the credential chain to production-safe credentials.- Wrap every client in a context manager so HTTP transports, sockets, and token caches are released deterministically:
- Sync:
with <Client>(...) as client:- Async:
async with <Client>(...) as client:andasync with DefaultAzureCredential() as credential:(fromazure.identity.aio)Snippets may abbreviate this setup, but production code should always follow both rules.
| Client | Purpose | Get From |
|---|---|---|
BlobServiceClient | Account-level operations | Direct instantiation |
ContainerClient | Container operations | blob_service_client.get_container_client() |
BlobClient | Single blob operations | container_client.get_blob_client() |
Generate SAS tokens with a user delegation key signed by Microsoft Entra ID — never with an account key. This keeps SAS issuance tied to Entra audit/rotation.
azure.storage.blob sync clients with azure.storage.blob.aio async clients in the same call path. Choose one mode per module.with BlobServiceClient(...) as client: (sync) or async with BlobServiceClient(...) as client: (async). For async DefaultAzureCredential from azure.identity.aio, also use async with credential: so tokens and transports are cleaned up.DefaultAzureCredential for code that runs locally (instead of connection strings). Use a specific token credential for code that runs in Azure.overwrite=True explicitly when re-uploadingmax_concurrency for large file transfersreadinto() over readall() for memory efficiencywalk_blobs() for hierarchical listing| File | Contents |
|---|---|
| references/capabilities.md | Capability index mapping hero flows and non-hero references. |
| references/non-hero-scenarios.md | Dedicated non-hero examples (metadata/properties and async patterns). |