編輯

共用方式為


適用於 Python 的 Azure 儲存體程式庫Azure Storage libraries for Python

概觀Overview

使用管理程式庫來建立、更新和管理 Azure 儲存體帳戶,並從您的 Python 程式碼查詢及重新產生存取金鑰。Create, update, and manage Azure Storage accounts and query and regenerate access keys from your Python code with the management libraries.

安裝程式庫Install the libraries

用戶端Client

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.