{"record":{"id":"9ee3279b1a0332a9","repo":"microsoft/semantic-kernel","slug":"error-missing-azure-cognitive-search-client-endpo","errorCode":null,"errorMessage":"Error: missing Azure Cognitive Search client endpoint.","messagePattern":"Error: missing Azure Cognitive Search client endpoint\\.","errorType":"validation","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/azure_cognitive_search/utils.py","lineNumber":50,"sourceCode":"    Args:\n        search_endpoint (str): Optional endpoint (default: {None}).\n        admin_key (str): Optional API key (default: {None}).\n        azure_credential (AzureKeyCredential): Optional Azure credentials (default: {None}).\n        token_credential (TokenCredential): Optional Token credential (default: {None}).\n    \"\"\"\n    ENV_VAR_ENDPOINT = \"AZURE_COGNITIVE_SEARCH_ENDPOINT\"\n    ENV_VAR_API_KEY = \"AZURE_COGNITIVE_SEARCH_ADMIN_KEY\"\n\n    # Load environment variables\n    load_dotenv()\n\n    # Service endpoint\n    if search_endpoint:\n        service_endpoint = search_endpoint\n    elif os.getenv(ENV_VAR_ENDPOINT):\n        service_endpoint = os.getenv(ENV_VAR_ENDPOINT)\n    else:\n        raise ServiceInitializationError(\"Error: missing Azure Cognitive Search client endpoint.\")\n\n    if service_endpoint is None:\n        print(service_endpoint)\n        raise ServiceInitializationError(\"Error: Azure Cognitive Search client not set.\")\n\n    # Credentials\n    if admin_key:\n        azure_credential = AzureKeyCredential(admin_key)\n    elif azure_credential:\n        azure_credential = azure_credential\n    elif token_credential:\n        token_credential = token_credential\n    elif os.getenv(ENV_VAR_API_KEY):\n        azure_credential = AzureKeyCredential(os.getenv(ENV_VAR_API_KEY))\n    else:\n        raise ServiceInitializationError(\"Error: missing Azure Cognitive Search client credentials.\")\n\n    if azure_credential is None and token_credential is None:","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/azure_cognitive_search/utils.py#L32-L68","documentation":"Raised in `get_search_index_async_client` (utils.py) when no search endpoint can be resolved: neither a `search_endpoint` argument nor the `AZURE_COGNITIVE_SEARCH_ENDPOINT` environment variable is provided (after `load_dotenv()`). The endpoint is mandatory to build a `SearchIndexClient`, so initialization fails with `ServiceInitializationError`.","triggerScenarios":"Calling `get_search_index_async_client(...)` (directly or via the memory store constructor) with `search_endpoint=None` while `AZURE_COGNITIVE_SEARCH_ENDPOINT` is unset in both the process environment and any loaded `.env` file.","commonSituations":"Forgotten env var; `.env` not on the path given by `env_file_path`; env var not exported in container/CI; typo in the variable name; deploying without provisioning an Azure Search service endpoint.","solutions":["Set `AZURE_COGNITIVE_SEARCH_ENDPOINT` in your environment or `.env` (e.g. `https://<service>.search.windows.net`).","Pass `search_endpoint=` explicitly to the store constructor / `get_search_index_async_client`.","Confirm `load_dotenv()` actually loads your `.env` (correct path and working directory).","Verify the Azure Search service is provisioned and its endpoint copied correctly."],"exampleFix":"// before\nget_search_index_async_client(admin_key=\"...\")  # no endpoint -> error\n\n// after\nget_search_index_async_client(\n    search_endpoint=\"https://mysearch.search.windows.net\",\n    admin_key=os.environ[\"AZURE_COGNITIVE_SEARCH_ADMIN_KEY\"],\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef acs_endpoint_resolved(endpoint_arg) -> str | None:\n    return endpoint_arg or os.getenv(\"AZURE_COGNITIVE_SEARCH_ENDPOINT\")\n\n# ep = acs_endpoint_resolved(search_endpoint)\n# assert ep, \"set AZURE_COGNITIVE_SEARCH_ENDPOINT or pass search_endpoint\"","typeGuard":"def has_acs_endpoint(endpoint_arg) -> bool:\n    import os\n    return bool(endpoint_arg or os.getenv(\"AZURE_COGNITIVE_SEARCH_ENDPOINT\"))","tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\ntry:\n    client = get_search_index_async_client(...)\nexcept ServiceInitializationError as e:\n    if \"missing ... endpoint\" in str(e):\n        raise SystemExit(\"set AZURE_COGNITIVE_SEARCH_ENDPOINT\") from e\n    raise","preventionTips":["Always set `AZURE_COGNITIVE_SEARCH_ENDPOINT` in env or `.env`.","Pass `search_endpoint=` explicitly in code to avoid env dependency.","Verify `load_dotenv()` loads the file from the expected path.","CI-inject the endpoint as a secret variable."],"tags":["azure-cognitive-search","endpoint","config","service-initialization","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}