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.
Module Attributes
account-key string, connection string, SAS string, dict of kwargs, |
Functions
|
Resolve a credential into a normalized form that can build a |
Classes
|
Holds a resolved credential and a lazy |
- class azuredol.connection.AzureConnection(credential=None, connection_string=None, account_url=None, account_key=None, client_kwargs=dict())[source]#
Bases:
objectHolds 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:
All four args are optional; the credential cascade in
resolve_credentialis consulted if none are provided.- blob_client(container, blob)[source]#
Cheap derivation of a
BlobClientfrom the shared service client.
- container_client(container)[source]#
Cheap derivation of a
ContainerClientfrom the shared service client.
- classmethod from_anything(source)[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)
- Return type:
- 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
- azuredol.connection.resolve_credential(*, credential=None, connection_string=None, account_url=None, account_key=None)[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:
- Raises:
ValueError – if no source resolves.