Azure Blob Storage library for Rust
Client library for Azure Blob Storage — upload, download, and manage blobs and containers.
Use this skill when:
- An app needs to upload or download blobs from Azure Storage in Rust
- You need to create or manage blob containers
- You need to list blobs with pagination
- You need RBAC-based auth for blob operations
IMPORTANT: Only use the official
azure_storage_blobcrate published by the azure-sdk crates.io user. Do NOT use the unofficialazure_storage,azure_storage_blobs, orazure_sdk_for_rustcommunity crates. Official crates use underscores in names and none have version 0.21.0.
Installation
If your code uses
azure_coretypes directly (for example,azure_core::http::Urlorazure_core::http::RequestContent), addazure_coretoCargo.toml. If you only useazure_storage_blobre-exports, directazure_coredependency is optional.
Environment Variables
When both are available, prefer constructing the endpoint from AZURE_STORAGE_ACCOUNT so the code matches common evaluation prompts.
Authentication
Rust Azure SDK code must not use DefaultAzureCredential. The Rust identity crate does not provide that type.
Client Types
Core Workflow
Upload Blob
Download Blob / Get Properties
Delete Blob
Container Operations
For azure_storage_blob 1.x, do not assume you need a nested page loop like for item in &page.blob_items. In this usage pattern, try_next() already yields the blob item you want to print.
Error Handling
Use StorageError for programmatic access to storage-specific error codes:
Note:
StorageError::try_intorequires an owned error object — it will not compile if handed a reference to an error.
RBAC Roles
For Entra ID auth, assign one of these roles to the identity:
Best Practices
- Use
cargo addto manage dependencies, never editCargo.tomldirectly. Add and remove Rust SDK dependencies with cargo commands instead of manual manifest edits. - Add
azure_coreonly when importingazure_coretypes directly. If your code importsazure_core::http::Url,azure_core::http::RequestContent, orazure_core::error::ErrorKind, includeazure_core; otherwise a direct dependency is optional. - Use
DeveloperToolsCredentialfor local dev,ManagedIdentityCredentialfor production — Rust does not provide a singleDefaultAzureCredentialtype - Never hardcode credentials — use environment variables or managed identity
- Use
RequestContent::from()to wrap data for blob uploads — ensures proper content handling by the SDK - Assign RBAC roles — ensure "Storage Blob Data Contributor" for write access
- Reuse clients — clients are thread-safe; create once, share across tasks
- Prefer
BlobServiceClientas the entry point and derive container/blob clients from it - Treat many storage model fields as optional.
blob.nameis anOption<String>and content length is accessed viablob.properties.as_ref().and_then(|p| p.content_length). - Run
cargo clippy -- -D warningsbefore considering the task complete when the prompt or CI expects strict lint compliance; fix style lints such as collapsibleifblocks, not just compiler errors. - Prefer crate README/examples over generated internal type names when validating public API shapes such as pagination results
- Future-proof
#[non_exhaustive]SDK models — when constructing SDK model/options structs, end the initializer with..Default::default()(add#[allow(clippy::needless_update)]) and use a_wildcard arm when matching SDK enums, so new service-added fields/variants don't break your build
Common Rust Blob Pitfalls
- Do not import
azure_identity::DefaultAzureCredential; useDeveloperToolsCredentialor another real Rust credential type. - Do not assume generated internal model names describe the public pager item type; follow the documented
list_blobsexample for this crate. - Do not print
blob.namewith{}directly; unwrap or provide a fallback because it is optional. - Do not stop after
cargo buildpasses when the task also requirescargo clippy -- -D warnings.



