Azure Blob Storage SDK for Python
使用 Python 处理 Azure Blob 存储
需要为您的应用程序管理云存储?本技能提供使用 Python SDK 上传、下载、列出和管理 Azure Blob 存储容器及 Blob 的知识。
下载技能 ZIP
在 Claude 中上传
前往 设置 → 功能 → 技能 → 上传技能
开启并开始使用
测试它
正在使用“Azure Blob Storage SDK for Python”。 How do I upload a file to Azure Blob Storage?
预期结果:
要上传文件,您需要使用账户凭据的 BlobServiceClient。获取特定容器和 Blob 名称的 BlobClient,然后使用 upload_blob() 上传文件数据。设置 overwrite=True 以替换现有 Blob。对于大文件,使用 max_concurrency 进行并行上传。
正在使用“Azure Blob Storage SDK for Python”。 What's the best way to handle large blob uploads?
预期结果:
对于超过 64MB 的大文件,Azure 自动使用块上传。配置 max_single_put_size 来控制阈值。使用 max_concurrency 启用并行上传。为获得最佳性能,请使用 4-8 个并发连接,并确保块大小为 4MB。
安全审计
安全Prompt-only documentation skill providing reference material for Azure Blob Storage SDK for Python. No executable code scanned. Static analysis found zero issues. This skill contains only markdown documentation for helping users interact with Azure Blob Storage operations - no scripts, network calls, or file operations.
质量评分
你能构建什么
构建数据管道
在本地系统和云存储之间移动数据,用于 ETL 工作流
提供静态网站资源
托管和服务静态文件,如图片、视频和文档
备份应用程序数据
存储数据库、日志和应用程序状态的备份
试试这些提示
帮我将名为'data.json'的文件上传到名为'backups'的 Azure Blob 存储容器中,使用 Python。
展示如何列出名为'documents'的容器中的所有 Blob,包括它们的大小和最后修改日期。
编写 Python 代码从 Blob 存储下载 500MB 文件,并使用并行下载以获得更好的性能。
创建一个具有读写权限且有效期为 1 小时的 SAS 令牌,并展示如何使用它访问 Blob。
最佳实践
- 使用 DefaultAzureCredential 而不是连接字符串以获得更好的安全性
- 上传用于 Web 服务的 Blob 时设置适当的 content-type 标题
- 使用 max_concurrency 参数进行大文件传输以提高性能
避免
- 在代码中存储账户密钥 - 始终使用 Azure Identity 或环境变量
- 使用 readall() 将整个大 Blob 下载到内存中 - 使用 readinto() 进行流式传输
- 使用硬编码的容器或 Blob 名称 - 使用配置以提高灵活性