{"record":{"id":"6645c0e5264e67c1","repo":"deepset-ai/haystack","slug":"please-provide-an-azure-endpoint-or-set-the-enviro-6645c0","errorCode":null,"errorMessage":"Please provide an Azure endpoint or set the environment variable AZURE_OPENAI_ENDPOINT.","messagePattern":"Please provide an Azure endpoint or set the environment variable AZURE_OPENAI_ENDPOINT\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"haystack/components/embedders/azure_text_embedder.py","lineNumber":107,"sourceCode":"            A string to add at the end of each text.\n        :param default_headers: Default headers to send to the AzureOpenAI client.\n        :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\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        # Why is this here?\n        # AzureOpenAI init is forcing us to use an init method that takes either base_url or azure_endpoint as not\n        # None init parameters. This way we accommodate the use case where env var AZURE_OPENAI_ENDPOINT is set instead\n        # of passing it as a parameter.\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.timeout = timeout\n        self.max_retries = max_retries\n        self.prefix = prefix\n        self.suffix = suffix\n        self.default_headers = default_headers or {}\n        self.azure_ad_token_provider = azure_ad_token_provider","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/embedders/azure_text_embedder.py#L89-L125","documentation":"AzureOpenAITextEmbedder requires an Azure OpenAI endpoint. In __init__, the azure_endpoint argument falls back to the AZURE_OPENAI_ENDPOINT environment variable; if neither is set, ValueError is raised, because the underlying AzureOpenAI client mandates a non-None endpoint. This is the text-embedder sibling of the document embedder check.","triggerScenarios":"Instantiating AzureOpenAITextEmbedder() with no azure_endpoint argument while AZURE_OPENAI_ENDPOINT is unset/empty in the environment.","commonSituations":"Env var not propagated to the runtime (Docker, serverless, CI); .env file not loaded; confusing AZURE_OPENAI_ENDPOINT with OPENAI_BASE_URL or an Azure deployment name (deployment goes to azure_deployment).","solutions":["Set AZURE_OPENAI_ENDPOINT=\"https://<your-resource>.openai.azure.com/\" in the environment, or pass azure_endpoint=... directly to the constructor.","Ensure the URL is the resource endpoint, not the deployment URL or a base_url.","Load your .env file before instantiating (python-dotenv) and confirm with os.environ.get(\"AZURE_OPENAI_ENDPOINT\")."],"exampleFix":"# before\nembedder = AzureOpenAITextEmbedder()  # ValueError\n# after\nembedder = AzureOpenAITextEmbedder(\n    azure_endpoint=\"https://my-resource.openai.azure.com/\",\n    azure_deployment=\"text-embedding-ada-002\",\n    api_key=\"<key>\",\n)","handlingStrategy":"validation","validationCode":"import os\n\nendpoint = azure_endpoint or os.environ.get(\"AZURE_OPENAI_ENDPOINT\")\nif not endpoint:\n    raise ValueError(\"Set AZURE_OPENAI_ENDPOINT or pass azure_endpoint to AzureOpenAITextEmbedder\")\nif not endpoint.startswith(\"https://\"):\n    raise ValueError(\"azure_endpoint must be the full resource URL, e.g. https://<resource>.openai.azure.com/\")","typeGuard":null,"tryCatchPattern":"try:\n    embedder = AzureOpenAITextEmbedder(azure_endpoint=endpoint, api_key=key)\nexcept ValueError as e:\n    if \"AZURE_OPENAI_ENDPOINT\" in str(e):\n        raise RuntimeError(\"Missing Azure endpoint; set AZURE_OPENAI_ENDPOINT or pass azure_endpoint explicitly\") from e\n    raise","preventionTips":["Set the endpoint env var in the same scope that launches the Python process","Load .env before importing/instantiating haystack components","Do not confuse azure_endpoint (resource URL) with azure_deployment (model deployment name)","Add a startup config validator that checks all required Azure env vars once at boot"],"tags":["python","azure","configuration","env-var","missing-credential"],"backgroundTag":"missing-env-var","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}