{"record":{"id":"e0f351d41754c3c8","repo":"BerriAI/litellm","slug":"azure-ad-authentication-failed-for-redis","errorCode":null,"errorMessage":"Azure AD authentication failed for Redis","messagePattern":"Azure AD authentication failed for Redis","errorType":"exception","errorClass":"AuthenticationError","httpStatus":null,"severity":"error","filePath":"litellm/_redis.py","lineNumber":314,"sourceCode":"        # Only include username when explicitly set — sending AUTH \"\" <token>\n        # is invalid for most ACL-configured Azure Redis instances.\n        username: Final = os.environ.get(\"REDIS_USERNAME\", \"\")\n        if username:\n            auth_args = (username, access_token)\n        else:\n            auth_args = (access_token,)\n\n        self.send_command(\"AUTH\", *auth_args, check_health=False)\n\n        try:\n            auth_response = self.read_response()\n        except AuthenticationWrongNumberOfArgsError:\n            # Fallback: try with just the token (Redis < 6 / no ACL)\n            self.send_command(\"AUTH\", access_token, check_health=False)\n            auth_response = self.read_response()\n\n        if str_if_bytes(auth_response) != \"OK\":\n            raise AuthenticationError(\"Azure AD authentication failed for Redis\")\n\n    # Attach the live credential object so async paths can wrap it in\n    # AzureADCredentialProvider for refresh-aware token retrieval. The raw\n    # client_id/tenant_id/secret are intentionally NOT exposed here — the\n    # credential closure already holds them.\n    ad_connect._azure_credential = credential\n    return ad_connect\n\n\ndef get_redis_url_from_environment():\n    if \"REDIS_URL\" in os.environ:\n        return os.environ[\"REDIS_URL\"]\n\n    if \"REDIS_HOST\" not in os.environ or \"REDIS_PORT\" not in os.environ:\n        raise ValueError(\"Either 'REDIS_URL' or both 'REDIS_HOST' and 'REDIS_PORT' must be specified for Redis.\")\n\n    if \"REDIS_SSL\" in os.environ and os.environ[\"REDIS_SSL\"].lower() == \"true\":\n        redis_protocol = \"rediss\"","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/_redis.py#L296-L332","documentation":"Error \"Azure AD authentication failed for Redis\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/_redis.py:314 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check Azure AD credentials for Redis (managed identity or service principal) and ensure the identity has access to the Redis cache."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}