{"record":{"id":"55c64838c3f40b27","repo":"microsoft/semantic-kernel","slug":"please-provide-a-valid-azure-ai-endpoint","errorCode":null,"errorMessage":"Please provide a valid Azure AI endpoint.","messagePattern":"Please provide a valid Azure AI endpoint\\.","errorType":"exception","errorClass":"AgentInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/azure_ai/azure_ai_agent.py","lineNumber":461,"sourceCode":"        endpoint: str | None = None,\n        api_version: str | None = None,\n        **kwargs: Any,\n    ) -> AIProjectClient:\n        \"\"\"Create the Azure AI Project client using the connection string.\n\n        Args:\n            credential: The credential\n            endpoint: The Azure AI Foundry endpoint\n            api_version: Optional API version to use\n            kwargs: Additional keyword arguments\n\n        Returns:\n            AIProjectClient: The Azure AI Project client\n        \"\"\"\n        if endpoint is None:\n            ai_agent_settings = AzureAIAgentSettings()\n            if not ai_agent_settings.endpoint:\n                raise AgentInitializationException(\"Please provide a valid Azure AI endpoint.\")\n            endpoint = ai_agent_settings.endpoint\n\n        client_kwargs: dict[str, Any] = {\n            **kwargs,\n            **({\"user_agent\": SEMANTIC_KERNEL_USER_AGENT} if APP_INFO else {}),\n        }\n\n        if api_version:\n            client_kwargs[\"api_version\"] = api_version\n\n        return AIProjectClient(\n            credential=credential,\n            endpoint=endpoint,\n            **client_kwargs,\n        )\n\n    # region Declarative Spec\n","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/azure_ai/azure_ai_agent.py#L443-L479","documentation":"Raised by AzureAIAgent.create_client when no endpoint argument is supplied AND AzureAIAgentSettings.endpoint resolves to empty. The AIProjectClient requires a Foundry endpoint, so without one it cannot be constructed. Surfaced as AgentInitializationException.","triggerScenarios":"Calling create_client(credential) with endpoint=None and the AZURE_AI_AGENT_ENDPOINT/AZURE_AI_ENDPOINT environment variable unset; .env file missing or not loaded; settings misconfigured so endpoint is empty.","commonSituations":"Local dev without the endpoint env var set; deployment to an environment where the secret was not injected; typo in the env var name; AzureAIAgent_SETTINGS pointed at the wrong connection string field; CI pipeline missing the variable.","solutions":["Set the endpoint env var (e.g. AZURE_AI_AGENT_ENDPOINT=https://<resource>.services.ai.azure.com/api/projects/<project>).","Pass endpoint explicitly: create_client(credential, endpoint='https://...').","Load a .env file (python-dotenv) in local dev and verify the variable is present.","Confirm AzureAIAgentSettings().endpoint is non-empty before calling create_client."],"exampleFix":"// before\nclient = AzureAIAgent.create_client(credential)  // no endpoint arg, no env\n// after\nclient = AzureAIAgent.create_client(\n    credential,\n    endpoint='https://my-foundry.services.ai.azure.com/api/projects/proj',\n)","handlingStrategy":"validation","validationCode":"def ensure_endpoint(endpoint=None):\n    from semantic_kernel.agents import AzureAIAgentSettings\n    endpoint = endpoint or AzureAIAgentSettings().endpoint\n    if not endpoint:\n        raise ValueError('Azure AI endpoint missing: set endpoint arg or AZURE_AI_AGENT_ENDPOINT env var')\n    return endpoint","typeGuard":"def has_endpoint(endpoint=None) -> bool:\n    return bool(endpoint or AzureAIAgentSettings().endpoint)","tryCatchPattern":"try:\n    client = AzureAIAgent.create_client(credential, endpoint=endpoint)\nexcept AgentInitializationException as e:\n    if 'endpoint' in str(e):\n        log.error('Set AZURE_AI_AGENT_ENDPOINT or pass endpoint=...')\n    raise","preventionTips":["Set AZURE_AI_AGENT_ENDPOINT in your environment/.env for local dev.","Pass endpoint explicitly in code that runs across environments.","Validate settings.endpoint is non-empty before calling create_client."],"tags":["azure-ai","configuration","environment","authentication","agent-initialization"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}