BerriAI/litellm · error · ValueError

Missing required environment variable…

Error message

Missing required environment variable: AZURE_STORAGE_ACCOUNT_NAME

What it means

AzureBlobStorageLogger reads its entire configuration from environment variables at construction; AZURE_STORAGE_ACCOUNT_NAME — the storage account hosting the ADLS Gen2 filesystem where logs are written — is mandatory with no constructor fallback and no default, so init fails immediately when it is absent. Note that only absence raises here: a typo'd account name passes init and fails later at request time.

Solutions

  1. Export AZURE_STORAGE_ACCOUNT_NAME=<storage account name> (the dns prefix of https://<account>.dfs.core.windows.net)
  2. Also set AZURE_STORAGE_FILE_SYSTEM — the very next check fires otherwise
  3. Provide auth: either AZURE_STORAGE_ACCOUNT_KEY (key auth) or the AZURE_STORAGE_TENANT_ID / CLIENT_ID / CLIENT_SECRET trio (token auth)
  4. Verify with `az storage account list -o table` that the name exists and is the intended account

Example fix

// before
export AZURE_STORAGE_ACCOUNT_KEY=...   # account name never set -> ValueError at init
// after
export AZURE_STORAGE_ACCOUNT_NAME="mystgacct"
export AZURE_STORAGE_FILE_SYSTEM="litellm-logs"
export AZURE_STORAGE_ACCOUNT_KEY=...
Defensive patterns

Strategy: validation

Validate before calling

import os

for var in ("AZURE_STORAGE_ACCOUNT_NAME", "AZURE_STORAGE_FILE_SYSTEM"):
    if not os.getenv(var):
        raise RuntimeError(f"azure_storage logger disabled: {var} is not set")
auth = (os.getenv("AZURE_STORAGE_ACCOUNT_KEY")
        or all(os.getenv(v) for v in (
            "AZURE_STORAGE_TENANT_ID", "AZURE_STORAGE_CLIENT_ID",
            "AZURE_STORAGE_CLIENT_SECRET")))
if not auth:
    raise RuntimeError("azure_storage logger needs ACCOUNT_KEY or the tenant/client trio")

Prevention

When it happens

Trigger: Enabling the azure_storage logger callback without provisioning/documented env; deploying the proxy to k8s with an incomplete ConfigMap/Secret; running locally with the vars in a .env that was never sourced; renaming the account without updating deployments.

Common situations: Teams set the auth vars (AZURE_STORAGE_ACCOUNT_KEY or the tenant/client trio) but forget the account name; multi-account subscriptions exporting the wrong one; CI pipelines that strip env.

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/96355e3518a01c51. Report an issue: GitHub.

Appendix: source

Thrown at litellm/integrations/azure_storage/azure_storage.py:42

class AzureBlobStorageLogger(CustomBatchLogger):
    def __init__(
        self,
        **kwargs,
    ):
        try:
            verbose_logger.debug("AzureBlobStorageLogger: in init azure blob storage logger")

            # Env Variables used for Azure Storage Authentication
            self.tenant_id = os.getenv("AZURE_STORAGE_TENANT_ID")
            self.client_id = os.getenv("AZURE_STORAGE_CLIENT_ID")
            self.client_secret = os.getenv("AZURE_STORAGE_CLIENT_SECRET")
            self.azure_storage_account_key: str | None = os.getenv("AZURE_STORAGE_ACCOUNT_KEY")

            # Required Env Variables for Azure Storage
            _azure_storage_account_name: Final = os.getenv("AZURE_STORAGE_ACCOUNT_NAME")
            if not _azure_storage_account_name:
                raise ValueError("Missing required environment variable: AZURE_STORAGE_ACCOUNT_NAME")
            self.azure_storage_account_name: str = _azure_storage_account_name
            _azure_storage_file_system: Final = os.getenv("AZURE_STORAGE_FILE_SYSTEM")
            if not _azure_storage_file_system:
                raise ValueError("Missing required environment variable: AZURE_STORAGE_FILE_SYSTEM")
            self.azure_storage_file_system: str = _azure_storage_file_system
            self.azure_storage_endpoint_suffix: str = (
                os.getenv("AZURE_STORAGE_ENDPOINT_SUFFIX") or AZURE_STORAGE_DEFAULT_ENDPOINT_SUFFIX
            )
            self._service_client = None
            # Time that the azure service client expires, in order to reset the connection pool and keep it fresh
            self._service_client_timeout: float | None = None

            # Internal variables used for Token based authentication
            self.azure_auth_token: str | None = None  # the Azure AD token to use for Azure Storage API requests
            self.token_expiry: datetime | None = None  # the expiry time of the currentAzure AD token

            asyncio.create_task(self.periodic_flush())
            self.flush_lock = asyncio.Lock()

View on GitHub (pinned to 77b7c6c40c)