azuredol.connection
Connection-layer for azuredol.
Owns the expensive resource (BlobServiceClient) and the credential cascade.
See misc/docs/architecture.md Layer A and misc/docs/design_decisions.md §6.
- class azuredol.connection.AzureConnection(credential: str | dict | Any | None = None, connection_string: str | None = None, account_url: str | None = None, account_key: str | None = None, client_kwargs: dict = <factory>)[source]
Holds a resolved credential and a lazy
BlobServiceClient.This is the dependency-injection seam for the whole package. Tests construct one pointing at Azurite without touching any store class.
- Parameters:
credential – explicit credential object, key string, or SAS string.
connection_string – full connection string (overrides
credential).account_url – storage account URL (with or without credential).
account_key – shared-key for the account.
All four args are optional; the credential cascade in
resolve_credentialis consulted if none are provided.- blob_client(container: str, blob: str)[source]
Cheap derivation of a
BlobClientfrom the shared service client.
- container_client(container: str)[source]
Cheap derivation of a
ContainerClientfrom the shared service client.
- classmethod from_anything(source) AzureConnection[source]
Convenience: build an
AzureConnectionfrom a thing-or-spec.- Accepts:
AzureConnection(returned as-is)BlobServiceClient(wrapped without further resolution)str(connection string)dict(passed as kwargs)None(defer to env / AAD)
- property service_client: BlobServiceClient
The lazily-constructed
BlobServiceClient. Cached for the connection’s lifetime.
- azuredol.connection.CredentialLike
account-key string, connection string, SAS string, dict of kwargs,
azure.identitycredential object, or None (defer to env / DefaultAzureCredential).- Type:
Any of
alias of
str|dict|Any|None
- azuredol.connection.resolve_credential(*, credential: str | dict | Any | None = None, connection_string: str | None = None, account_url: str | None = None, account_key: str | None = None) dict[source]
Resolve a credential into a normalized form that can build a
BlobServiceClient.Cascade (first hit wins):
Explicit
credential=Explicit
connection_string=Explicit
account_url=+account_key=(or justaccount_url=+ AAD)Env var
AZURE_STORAGE_CONNECTION_STRINGEnv vars
AZURE_STORAGE_ACCOUNT_URL+AZURE_STORAGE_ACCOUNT_KEYEnv var
AZURE_STORAGE_ACCOUNT_URLalone +DefaultAzureCredential
- Returns:
{"conn_str": "..."}# for from_connection_string{"account_url": "...", "credential": <obj>}# for __init__- Return type:
A dict with one of these shapes
- Raises:
ValueError – if no source resolves.