{"record":{"id":"e691e628dbac0290","repo":"BerriAI/litellm","slug":"azure-identity-is-required-for-azure-ad-redis-auth","errorCode":null,"errorMessage":"azure-identity is required for Azure AD Redis authentication. Install it with: pip install azure-identity","messagePattern":"azure-identity is required for Azure AD Redis authentication\\. Install it with: pip install azure-identity","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"litellm/_redis.py","lineNumber":232,"sourceCode":"def _build_azure_credential(\n    azure_client_id: str | None = None,\n    azure_tenant_id: str | None = None,\n    azure_client_secret: str | None = None,\n):\n    \"\"\"\n    Build a long-lived Azure credential object.\n\n    Azure SDK credentials cache tokens internally and handle expiry/refresh\n    transparently, so this should be called once and the result reused.\n    \"\"\"\n    try:\n        from azure.identity import (\n            ClientSecretCredential,\n            DefaultAzureCredential,\n            ManagedIdentityCredential,\n        )\n    except ImportError:\n        raise ImportError(\n            \"azure-identity is required for Azure AD Redis authentication. Install it with: pip install azure-identity\"\n        )\n\n    _client_id: Final = azure_client_id or os.environ.get(\"AZURE_CLIENT_ID\")\n    _tenant_id: Final = azure_tenant_id or os.environ.get(\"AZURE_TENANT_ID\")\n    _client_secret: Final = azure_client_secret or os.environ.get(\"AZURE_CLIENT_SECRET\")\n\n    if _client_id and _tenant_id and _client_secret:\n        return ClientSecretCredential(\n            client_id=_client_id,\n            tenant_id=_tenant_id,\n            client_secret=_client_secret,\n        )\n    elif _client_id:\n        return ManagedIdentityCredential(client_id=_client_id)\n    else:\n        return DefaultAzureCredential()\n","sourceCodeStart":214,"sourceCodeEnd":250,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/_redis.py#L214-L250","documentation":"When Azure AD auth is enabled for Redis (azure_redis_ad_token / REDIS_AZURE_AD_TOKEN set), litellm builds an Entra ID credential via azure.identity. If that package is not installed, the import fails and litellm re-raises ImportError telling you to pip install azure-identity. It is a missing optional dependency for the Azure Redis auth path.","triggerScenarios":"Enabling Azure AD Redis auth (azure_redis_ad_token=true or env REDIS_AZURE_AD_TOKEN=true) in an environment where azure-identity is not installed — slim docker images, minimal pip installs of litellm without the proxy/extra deps.","commonSituations":"Self-built minimal containers that pip install litellm only; CI environments caching a partial dependency set; enabling AAD auth on an existing deployment without adding the new dependency.","solutions":["pip install azure-identity (match your azure SDK stack, e.g. azure-identity>=1.12)","Or install the broader extra: pip install 'litellm[proxy]'","Rebuild your docker image / refresh requirements and redeploy","If you did not intend Azure AD auth, unset REDIS_AZURE_AD_TOKEN and remove azure_redis_ad_token from cache config"],"exampleFix":"# before\nexport REDIS_AZURE_AD_TOKEN=true\nlitellm --config config.yaml  # ImportError: azure-identity is required ...\n\n# after\npip install azure-identity\nexport REDIS_AZURE_AD_TOKEN=true\nlitellm --config config.yaml","handlingStrategy":"validation","validationCode":"import importlib.util\n\nif importlib.util.find_spec(\"azure.identity\") is None:\n    raise SystemExit(\n        \"azure-identity is required for Azure AD Redis auth: pip install azure-identity\"\n    )","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add azure-identity to your requirements whenever REDIS_AZURE_AD_TOKEN can be enabled","Bake the dependency into the docker image rather than relying on litellm's optional extras","Add a dependency smoke test (import azure.identity) to CI for images that use Azure Redis"],"tags":["redis","azure","dependency","importerror","active-directory","cache"],"backgroundTag":"missing-dependency","analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}