【Azurite】Python Azurite

Introduce and Install Azurite

Azurite is a local emulator for Azure Storage. It provides a local environment for testing and developing with Azure Storage.

Reference:

Quick Start

  1. Install Azurite with docker
docker pull mcr.microsoft.com/azure-storage/azurite
  1. Run Azurite with docker
docker run -p 10000:10000 -p 10001:10001 -p 10002:10002 \
    mcr.microsoft.com/azure-storage/azurite
``

3. Connect to Azurite with Storage Explorer
- Open Azure Storage Explorer
- Add a new connection
- Attach to local emulator

4. Use Azurite Python SDK to connect to Azurite

Install Azurite Python SDK
```bash
pip install azure-storage-blob
from azure.storage.blob import BlobServiceClient
import os


def test_generate_tests():
    os.environ["AZURE_STORAGE_CONNECTION_STRING"] = (
        "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10022/devstoreaccount1;"
    )
    os.environ["STORAGE_CONTAINER"] = "test-container"

    # Create a container for Azurite for the first run
    blob_service_client = BlobServiceClient.from_connection_string(
        os.environ.get(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值