{"record":{"id":"81d9c592e0874ee3","repo":"deepset-ai/haystack","slug":"please-provide-an-azure-endpoint-or-set-the-enviro-81d9c5","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/generators/chat/azure.py","lineNumber":210,"sourceCode":"        :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        # 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        # `azure_endpoint` accepts either a plain string or a `Secret`. We keep the original value on the instance for\n        # serialization and resolve it to a string only to validate that an endpoint was provided.\n        resolved_azure_endpoint = (\n            azure_endpoint.resolve_value() if isinstance(azure_endpoint, Secret) else azure_endpoint\n        )\n        if not resolved_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        # The check above makes mypy incorrectly infer that api_key is never None,\n        # which propagates the incorrect type.\n        self.api_key = api_key  # type: ignore\n        self.azure_ad_token = azure_ad_token\n        self.generation_kwargs = generation_kwargs or {}\n        self.streaming_callback = streaming_callback\n        self.api_version = api_version\n        self.azure_endpoint = azure_endpoint\n        self.azure_deployment = azure_deployment\n        self.organization = organization\n        self.model = azure_deployment or \"gpt-4.1-mini\"\n        self.timeout = timeout\n        self.max_retries = max_retries\n        self.default_headers = default_headers or {}","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/deepset-ai/haystack/blob/e318778c9bf60a1963e3b5f451359655dd696c30/haystack/components/generators/chat/azure.py#L192-L228","documentation":"AzureOpenAIChatGenerator needs an Azure OpenAI endpoint URL. If neither the azure_endpoint parameter nor the AZURE_OPENAI_ENDPOINT environment variable provides one, __init__ raises ValueError.","triggerScenarios":"Constructing AzureOpenAIChatGenerator() with azure_endpoint=None and no AZURE_OPENAI_ENDPOINT env var set (also no AZURE_OPENAI_SK/Secret resolution yielding a value).","commonSituations":"Deploying to an environment where the .env file wasn't loaded; running in CI where the env var is unset; typo in the environment variable name; passing an empty string as the endpoint.","solutions":["Pass azure_endpoint=\"https://<your-resource>.openai.azure.com/\" to the constructor","Set the AZURE_OPENAI_ENDPOINT environment variable before running the app","Verify the .env file is loaded (e.g. python-dotenv) and the variable name is spelled correctly"],"exampleFix":"// before\ngenerator = AzureOpenAIChatGenerator()  # no endpoint anywhere\n// after\nimport os\ngenerator = AzureOpenAIChatGenerator(azure_endpoint=os.environ[\"AZURE_OPENAI_ENDPOINT\"])\n# or set the env var: export AZURE_OPENAI_ENDPOINT=https://my-resource.openai.azure.com/","handlingStrategy":"validation","validationCode":"import os\nendpoint = azure_endpoint or os.getenv(\"AZURE_OPENAI_ENDPOINT\")\nif not endpoint:\n    raise ValueError(\"Set azure_endpoint or AZURE_OPENAI_ENDPOINT\")","typeGuard":null,"tryCatchPattern":"try:\n    generator = AzureOpenAIChatGenerator(azure_endpoint=endpoint)\nexcept ValueError as e:\n    logger.error(\"Azure configuration error: %s\", e)\n    raise","preventionTips":["Set AZURE_OPENAI_ENDPOINT in every environment (dev, CI, prod)","Load .env files explicitly (python-dotenv) before constructing the generator","Centralize Azure config in one factory function that validates presence of all required values"],"tags":["azure","configuration","missing-env-var"],"backgroundTag":"missing-env-var","analyzedSha":"e318778c9bf60a1963e3b5f451359655dd696c30","analyzedAt":"2026-08-30T11:45:20.711Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}