yera.providers.azure_common

Shared Azure credential and logging helpers.

Centralises credential construction so setup, discovery, and runtime all acquire tokens against the same tenant. Azure OpenAI supports AAD bearer tokens natively, so Yera never stores an API key for this provider.

Symbols

def build_azure_credential — Build a DefaultAzureCredential pinned to a specific tenant.
def build_azure_openai_client — Build an OpenAI client for Azure's stable v1 data plane.
def suppress_azure_logging — Silence chatty INFO-level logs from the Azure SDK chain.

build_azure_credential

build_azure_credential(
    tenant_id: str,
) → DefaultAzureCredential

Build a DefaultAzureCredential pinned to a specific tenant.

additionally_allowed_tenants ensures the credential chain can acquire tokens for tenant_id even when the active Azure CLI context points elsewhere — which is the common failure mode for users with multiple Azure identities.

Parameters

tenant_id
type: str

The AAD tenant UUID this credential should target.

Returns

type: DefaultAzureCredential

A DefaultAzureCredential that will try managed identity, workload identity, env vars, Azure CLI, and developer tools in order — all constrained to the given tenant.

build_azure_openai_client

build_azure_openai_client(
    connection: AzureConnection,
) → OpenAI

Build an OpenAI client for Azure's stable v1 data plane.

Constructs a tenant-pinned credential, wraps it in a token provider scoped to the Azure AI data plane, and supplies that provider to the ordinary OpenAI client. Azure's stable v1 endpoint does not require a dated API-version parameter.

Parameters

connection
type: AzureConnection

Azure connection supplying the tenant ID and endpoint URL.

Returns

type: OpenAI

An OpenAI client configured for the Azure v1 endpoint with Entra token-based authentication.

suppress_azure_logging

suppress_azure_logging() → None

Silence chatty INFO-level logs from the Azure SDK chain.

DefaultAzureCredential logs every credential method it tries — and, when unauthenticated, every one it fails — on azure.identity, at WARNING. The token library (msal) and the HTTP pipeline add more. Raising the threshold to ERROR keeps genuine failures visible while dropping the per-attempt noise.

Call before any operation that touches azure.* modules.