BerriAI/litellm · error · ValueError

Missing required environment variable: AZURE_STORAGE_ACCOUNT

Error message

Missing required environment variable: AZURE_STORAGE_ACCOUNT_NAME

What it means

The AzureBlobStorageLogger (custom callback that writes litellm logs to ADLS Gen2) reads its storage account name exclusively from the AZURE_STORAGE_ACCOUNT_NAME environment variable — there is no constructor parameter fallback. If unset/empty at logger init, it raises ValueError immediately. Note this init code sits inside a try block; the ValueError may be caught by the surrounding handler depending on caller.

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 6c2dcb801b)

Solutions

  1. Export AZURE_STORAGE_ACCOUNT_NAME=<account-name> (bare name, no URL) in the environment where litellm runs
  2. Set AZURE_STORAGE_FILE_SYSTEM too — init checks it right after (see error 330)
  3. Optionally configure AZURE_STORAGE_TENANT_ID/CLIENT_ID/CLIENT_SECRET (or ACCOUNT_KEY) for auth
  4. For Docker/K8s deployments add the variable to the container/pod spec and restart

Example fix

# before
# env: nothing set -> ValueError: Missing required environment variable: AZURE_STORAGE_ACCOUNT_NAME

# after
export AZURE_STORAGE_ACCOUNT_NAME=mystorageaccount
export AZURE_STORAGE_FILE_SYSTEM=mycontainer
export AZURE_STORAGE_TENANT_ID=<guid>
export AZURE_STORAGE_CLIENT_ID=<guid>
export AZURE_STORAGE_CLIENT_SECRET=<secret>
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"Missing required environment variable: {var}")

name = os.getenv("AZURE_STORAGE_ACCOUNT_NAME", "")
assert "/" not in name and "http" not in name, "use the bare account name, not a URL"

Type guard

def is_bare_account_name(v: str | None) -> bool:
    return isinstance(v, str) and v != "" and "/" not in v and not v.startswith("http")

Try / catch

try:
    AzureBlobStorageLogger()
except ValueError as e:
    if "AZURE_STORAGE_ACCOUNT_NAME" in str(e):
        raise SystemExit("Set AZURE_STORAGE_ACCOUNT_NAME to the bare storage account name") from e
    raise

Prevention

When it happens

Trigger: Enabling the azure_storage callback (litellm.callbacks=['azure_storage'] or proxy config) without AZURE_STORAGE_ACCOUNT_NAME in the process env; env var set only in the proxy container but logs written from a worker; name misspelled.

Common situations: Following the Azure Storage docs page but skipping the env setup step; deploying via Docker/K8s where the env var was added to one service but not the logging path; account name confused with the full URL (must be the bare account name, e.g. mystorageaccount not https://mystorageaccount.dfs.core.windows.net).

Related errors


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