azure-storage-blob-rust
它能做什么
这个工具可以帮助用 Rust 编写的程序,在微软 Azure 云存储中存储和读取文件(称为 'blob')。你可以用它上传、下载和管理这些文件。
适用场景
- ✓当你的程序需要把大文件保存到云端时。
- ✓当你的程序需要下载存储在云端的文件时。
- ✓当你的程序需要列出或删除某个云端位置中的文件时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/azure-storage-blob-rust/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我的 Rust 程序如何把文件上传到 Azure Blob Storage?”
每周 5 个新技能,1 分钟读完。
工作原理
程序会使用一个名为 'library'(库)的 SDK 与 Azure 通信。它需要先获得访问信息,然后使用特定的命令上传、下载或管理文件。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Azure Blob Storage SDK for Rust
Client library for Azure Blob Storage — Microsoft's object storage solution for the cloud.
The examples below require a reviewed compatible crate set and replacement of every resource placeholder. Do not use production data for demonstration writes.
Installation
cargo add azure_storage_blob@=1.1.0 azure_identity@=1.0.0 azure_core@=1.1.0
Environment Variables
export AZURE_STORAGE_ACCOUNT_NAME="<storage-account-name>"
# Endpoint: https://<account>.blob.core.windows.net/
Authentication
use azure_identity::DeveloperToolsCredential;
use azure_core::http::Url;
use azure_storage_blob::clients::{BlobClient, BlobClientOptions};
let credential = DeveloperToolsCredential::new(None)?;
let blob_client = BlobClient::new(
Url::parse("https://<account>.blob.core.windows.net/container-name/blob-name")?,
Some(credential),
Some(BlobClientOptions::default()),
)?;
Client Types
| Client | Purpose |
|---|---|
BlobServiceClient |
Account-level operations, list containers |
BlobContainerClient |
Container operations, list blobs |
BlobClient |
Individual blob operations |
Core Operations
Upload Blob
use azure_core::http::RequestContent;
use azure_storage_blob::models::BlobClientUploadOptions;
let data = b"hello world";
blob_client
.upload(
RequestContent::from(data.to_vec()),
Some(BlobClientUploadOptions::if_not_exists()), // fail rather than overwrite an existing blob
)
.await?;
Download Blob
let response = blob_client.download(None).await?;
// Check the approved size before fetching; use download_into with a bounded buffer for large data.
let content = response.body.collect().await?;
// Process authorized bytes; do not log the payload.
Get Blob Properties
let properties = blob_client.get_properties(None).await?;
// Read the version-specific response header trait; properties is a response, not a content_length field.
// Do not infer a body/size limit from successful metadata access alone.
Delete Blob
blob_client.delete(None).await?;
Container Operations
use azure_storage_blob::clients::BlobContainerClient;
use futures::TryStreamExt;
let container_client = BlobContainerClient::new(
Url::parse("https://<account>.blob.core.windows.net/container-name")?,
Some(credential),
None,
)?;
// Create container
container_client.create(None).await?;
// List blobs
let mut pager = container_client.list_blobs(None)?;
while let Some(page) = pager.try_next().await? {
let listing = page.into_model()?;
// Process this listing page; apply an explicit maximum-page budget.
}
Best Practices
- Use Entra ID auth —
DeveloperToolsCredentialfor dev,ManagedIdentityCredentialfor production - Review overwrite behavior — the reviewed upload API uses options; if_not_exists prevents unintended replacement
- Use
RequestContent::from()— to wrap upload data - Handle async operations — use
tokioruntime - Check RBAC permissions — ensure "Storage Blob Data Contributor" role
RBAC Permissions
For Entra ID auth, assign one of these roles:
Storage Blob Data Reader— read-onlyStorage Blob Data Contributor— read/writeStorage Blob Data Owner— blob-data access and supported ownership/ACL management; it does not grant general Azure RBAC role-assignment authority
The example API follows BlobClient 1.1.0; earlier releases used different constructor/upload signatures. Use the project’s compatible Azure crate versions rather than mixing them.
The reviewed example set uses azure_storage_blob 1.1.0 and compatible Azure core/credential crates. Record and commit Cargo.lock; source/API review is not a compiler or live-service test.
Reference Links
| Resource | Link |
|---|---|
| API Reference | https://docs.rs/azure_storage_blob |
| Source Code | https://github.com/Azure/azure-sdk-for-rust/tree/main/sdk/storage/azure_storage_blob |
| crates.io | https://crates.io/crates/azure_storage_blob |
When to Use
Use when a Rust application uploads/downloads a specified Azure blob, reads its properties or manages an authorized container.
Limitations
…
常见问题
什么是 'blob'?
'blob' 是一个技术术语,指存储在 Azure 中的文件,比如照片、文档或任何其他类型的数据。
什么是“云存储”?
它是指把文件存放在你通过互联网访问的远程服务器上,而不是存在自己的电脑里。
使用这个工具需要懂 Azure 编程吗?
这个 SDK 面向已经会用 Rust 编程的人。它简化了与 Azure 的交互,但你仍需要了解 Azure 的基本工作原理以及如何用 Rust 编程。
详情
作者的原始描述
Azure Blob Storage SDK for Rust. Use for uploading, downloading, and managing blobs and containers.
热度
- GitHub 星标
- 48k
- 排名
- #3994
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。