{"record":{"id":"318bd247655c03ca","repo":"deepset-ai/haystack","slug":"please-provide-an-api-key-or-an-azure-active-direc","errorCode":null,"errorMessage":"Please provide an API key or an Azure Active Directory token.","messagePattern":"Please provide an API key or an Azure Active Directory token\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"haystack/components/embedders/azure_document_embedder.py","lineNumber":124,"sourceCode":"        :param azure_ad_token_provider: A function that returns an Azure Active Directory token, will be invoked on\n            every request.\n        :param http_client_kwargs:\n            A dictionary of keyword arguments to configure a custom `httpx.Client`or `httpx.AsyncClient`.\n            For more information, see the [HTTPX documentation](https://www.python-httpx.org/api/#client).\n        :param raise_on_failure:\n            Whether to raise an exception if the embedding request fails. If `False`, the component will log the error\n            and continue processing the remaining documents. If `True`, it will raise an exception on failure.\n        \"\"\"\n        # We intentionally do not call super().__init__ here because we only need to instantiate the client to interact\n        # with the API.\n\n        # if not provided as a parameter, azure_endpoint is read from the env var AZURE_OPENAI_ENDPOINT\n        azure_endpoint = azure_endpoint or os.environ.get(\"AZURE_OPENAI_ENDPOINT\")\n        if not azure_endpoint:\n            raise ValueError(\"Please provide an Azure endpoint or set the environment variable AZURE_OPENAI_ENDPOINT.\")\n\n        if api_key is None and azure_ad_token is None:\n            raise ValueError(\"Please provide an API key or an Azure Active Directory token.\")\n\n        self.api_key = api_key  # type: ignore[assignment] # mypy does not understand that api_key can be None\n        self.azure_ad_token = azure_ad_token\n        self.api_version = api_version\n        self.azure_endpoint = azure_endpoint\n        self.azure_deployment = azure_deployment\n        self.model = azure_deployment\n        self.dimensions = dimensions\n        self.organization = organization\n        self.prefix = prefix\n        self.suffix = suffix\n        self.batch_size = batch_size\n        self.progress_bar = progress_bar\n        self.meta_fields_to_embed = meta_fields_to_embed or []\n        self.embedding_separator = embedding_separator\n        self.timeout = timeout\n        self.max_retries = max_retries\n        self.default_headers = default_headers or {}","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/embedders/azure_document_embedder.py#L106-L142","documentation":"AzureOpenAIDocumentEmbedder requires credentials: at least one of api_key or azure_ad_token must be provided (api_key may alternatively come from the AZURE_OPENAI_API_KEY env var per the Azure SDK). If both are None, ValueError is raised. The component intentionally skips super().__init__, so this validation happens explicitly in its __init__.","triggerScenarios":"Instantiating AzureOpenAIDocumentEmbedder() with neither api_key nor azure_ad_token arguments while AZURE_OPENAI_API_KEY is also unset in the environment.","commonSituations":"Switching to Azure AD/managed-identity auth but forgetting the token; new resource created but key not yet copied into secrets; CI/CD secrets not injected; deliberately omitting the key expecting an interactive prompt (none exists).","solutions":["Provide api_key=<your Azure OpenAI key> (or ensure AZURE_OPENAI_API_KEY is set in the environment).","Or pass azure_ad_token=<AAD token> for token-based auth; for managed identity consider using azure_ad_token generated via azure.identity DefaultAzureCredential.","Verify the secret is actually injected in your runtime environment (CI variables, mounted secrets)."],"exampleFix":"# before\nembedder = AzureOpenAIDocumentEmbedder(azure_endpoint=endpoint)  # no credentials\n# after\nimport os\nembedder = AzureOpenAIDocumentEmbedder(\n    azure_endpoint=endpoint,\n    api_key=os.environ[\"AZURE_OPENAI_API_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\napi_key = api_key or os.environ.get(\"AZURE_OPENAI_API_KEY\")\nif not api_key and not azure_ad_token:\n    raise ValueError(\"Provide api_key or azure_ad_token for AzureOpenAIDocumentEmbedder\")","typeGuard":null,"tryCatchPattern":"try:\n    embedder = AzureOpenAIDocumentEmbedder(azure_endpoint=endpoint, api_key=key)\nexcept ValueError as e:\n    if \"API key\" in str(e):\n        raise RuntimeError(\"No Azure OpenAI credentials found; check AZURE_OPENAI_API_KEY or AAD token setup\") from e\n    raise","preventionTips":["Fetch the key from your secret manager and inject it via environment variables","For Azure AD auth, generate the token with azure.identity DefaultAzureCredential before construction","Check CI/CD secret bindings so AZURE_OPENAI_API_KEY reaches the runtime process","Fail fast at startup: assert credentials exist before building the pipeline"],"tags":["python","azure","authentication","api-key","missing-credential"],"backgroundTag":"missing-api-key","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}