您现在访问的是微软AZURE全球版技术文档网站,若需要访问由世纪互联运营的MICROSOFT AZURE中国区技术文档网站,请访问 https://docs.azure.cn.

用于 Python 的 Azure 存储库Azure Storage libraries for Python

概述Overview

使用管理库通过 Python 代码创建、更新和管理 Azure 存储帐户,以及查询和重新生成访问密钥。Create, update, and manage Azure Storage accounts and query and regenerate access keys from your Python code with the management libraries.

安装库Install the libraries

ClientClient

Azure 存储客户端库包含 4 个包:Blob、文件、队列和表。Azure Storage Client Libraries consist of 4 packages: Blob, File, Queue and Table. 若要安装 Blob 包,请运行:To install the blob package, run:

pip install azure-storage-blob

管理Management

pip install azure-mgmt-storage

示例Example

from azure.storage.blob import BlockBlobService

blob_service = BlockBlobService(account_name, account_key)

blob_service.create_container(
    'mycontainername',
    public_access=PublicAccess.Blob
)

blob_service.create_blob_from_bytes(
    'mycontainername',
    'myblobname',
    b'<center><h1>Hello World!</h1></center>',
    content_settings=ContentSettings('text/html')
)

print(blob_service.make_blob_url('mycontainername', 'myblobname'))

示例Samples

在 Python 中开始使用 Azure Blob 存储Get started with Azure Blob Storage in Python 在 Azure 存储中创建、读取、更新、限制访问和删除文件与对象。Create, read, update, restrict access, and delete files and objects in Azure Storage.
在 Python 中开始使用 Azure 队列存储Get started with Azure Queue Storage in Python 在 Azure 存储队列中插入、扫视、检索和删除消息。Insert, peek, retrieve and delete messages from Azure Storage queues.
管理 Azure 存储帐户Manage Azure Storage accounts 创建、更新和删除存储帐户。Create, update , and delete storage accounts. 检索和重新生成存储帐户访问密钥。Retrieve and regenerate storage account access keys.

详细了解可在应用中使用的示例 Python 代码Explore more sample Python code you can use in your apps.