Skip to main content

Async Azure Clients Mulligan Python projects

Project description

AIO Azure Clients Toolbox

Tests PyPI version Python 3.11+ Documentation

High-performance async Python library for Azure SDK clients with intelligent connection pooling.

Features

  • Async apps: Built for high-concurrency async applications: we have used this in production at Mulligan Funding for a few years.
  • 20-100x Performance Improvement: Connection pooling reduces operation latency for some services from 100-900ms to 1-5ms.
  • Intelligent Connection Management: Automatic lifecycle management with semaphore-based client limiting.
  • Azure SDK Integration: Wrappers for Cosmos DB, EventHub, Service Bus, Blob Storage, and EventGrid.
  • Testing Utilities: Includes pytest fixtures for mocking Azure services.

Useful Docs

Installation

pip install aio-azure-clients-toolbox

Quick Start

from azure.identity.aio import DefaultAzureCredential
from aio_azure_clients_toolbox import ManagedCosmos

# Traditional approach - slow
cosmos_client = CosmosClient(endpoint, credential)
container = cosmos_client.get_database("db").get_container("container")
await container.create_item({"id": "1"})  # 200ms+ including connection setup

# Connection pooled approach - fast
cosmos_client = ManagedCosmos(
    endpoint="https://your-cosmos.documents.azure.com:443/",
    dbname="your-database",
    container_name="your-container",
    credential=DefaultAzureCredential(),

    # Pool configuration
    client_limit=100,      # Concurrent clients per connection
    max_size=10,           # Maximum connections in pool
    max_idle_seconds=300   # Connection idle timeout
)

async with cosmos_client.get_container_client() as container:
    await container.create_item({"id": "1"})  # 2ms after pool warmup

Supported Azure Services

Service Managed Client Features
Cosmos DB ManagedCosmos Document operations with connection pooling
Event Hub ManagedAzureEventhubProducer Event streaming with persistent connections
Service Bus ManagedAzureServiceBusSender Message queuing with connection management
Blob Storage AzureBlobStorageClient File operations with SAS token support
Event Grid EventGridClient Event publishing to multiple topics

Testing Support

Also includes, built-in pytest fixtures for easy testing:

# tests/conftest.py
pytest_plugins = [
    "aio_azure_clients_toolbox.testing_utils.fixtures",
]

# Use in your tests
async def test_cosmos_operations(cosmos_insertable, document):
    container_client, set_return = cosmos_insertable
    set_return("success")
    result = await cosmos_client.insert_doc(document)
    assert result == "success"

Full Client Documentation

For detailed examples and advanced usage patterns, see the complete documentation.

Azure BlobStorage

from aio_azure_clients_toolbox import AzureBlobStorageClient

client = AzureBlobStorageClient(
    az_storage_url="https://account.blob.core.windows.net",
    container_name="my-container",
    az_credential=DefaultAzureCredential()
)

# Upload and download with SAS token support
await client.upload_blob("file.txt", b"content")
data = await client.download_blob("file.txt")
sas_url = await client.get_blob_sas_url("file.txt")

CosmosDB

from aio_azure_clients_toolbox import ManagedCosmos

client = ManagedCosmos(
    endpoint="https://your-account.documents.azure.com:443/",
    dbname="your-database",
    container_name="your-container",
    credential=DefaultAzureCredential()
)
# Document operations
async with cosmos.get_container_client() as container:
    # Create document
    document = {"id": "1", "name": "example", "category": "test"}
    result = await container.create_item(body=document)

    # Read document
    item = await container.read_item(item="1", partition_key="test")

EventGrid

from aio_azure_clients_toolbox.clients.eventgrid import EventGridClient, EventGridConfig

client = EventGridClient(
    config=EventGridConfig([
        EventGridTopicConfig("topic1", "https://topic1.azure.net/api/event"),
        EventGridTopicConfig("topic2", "https://topic2.azure.net/api/event"),
    ]),
    async_credential=DefaultAzureCredential()
)

await client.async_emit_event("topic1", "event-type", "subject", {"data": "value"})

EventHub

from aio_azure_clients_toolbox import ManagedAzureEventhubProducer

client = ManagedAzureEventhubProducer(
    eventhub_namespace="my-namespace.servicebus.windows.net",
    eventhub_name="my-hub",
    credential=DefaultAzureCredential()
)

await client.send_event('{"event": "data"}')

Service Bus

from aio_azure_clients_toolbox import ManagedAzureServiceBusSender

client = ManagedAzureServiceBusSender(
    service_bus_namespace="my-namespace.servicebus.windows.net",
    queue_name="my-queue",
    credential=DefaultAzureCredential()
)

await client.send_message("Hello, Service Bus!")

# Receiving messages
async with client.get_receiver() as receiver:
    async for message in receiver:
        await process_message(message)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aio_azure_clients_toolbox-1.4.0.tar.gz (52.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aio_azure_clients_toolbox-1.4.0-py3-none-any.whl (59.2 kB view details)

Uploaded Python 3

File details

Details for the file aio_azure_clients_toolbox-1.4.0.tar.gz.

File metadata

File hashes

Hashes for aio_azure_clients_toolbox-1.4.0.tar.gz
Algorithm Hash digest
SHA256 b72b7197ea3e1653f9f3865b0ae97f7b862ed8e086522610251be97fdf6d4168
MD5 3a80c9bdf34ae0cff126fdc42a3ea061
BLAKE2b-256 ce5dadbaf17cd44107d9b6e95b890039b89de38ef3a68d2ed2b25e5cc698401a

See more details on using hashes here.

Provenance

The following attestation bundles were made for aio_azure_clients_toolbox-1.4.0.tar.gz:

Publisher: release.yaml on MulliganFunding/aio-azure-clients-toolbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aio_azure_clients_toolbox-1.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aio_azure_clients_toolbox-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88dd8060e9103ef603a3535712d7c916c6c9ac89bbf76f273caa847e292c6573
MD5 4ab25ad6bcdc5d622e62c63ff6e67680
BLAKE2b-256 0110b9bb91a6ae8ecf3fa110c00e94e99a981f534c05cb69f0a9f5925e699e20

See more details on using hashes here.

Provenance

The following attestation bundles were made for aio_azure_clients_toolbox-1.4.0-py3-none-any.whl:

Publisher: release.yaml on MulliganFunding/aio-azure-clients-toolbox

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page