{"record":{"id":"38864b292ff6c707","repo":"microsoft/semantic-kernel","slug":"failed-to-create-azure-cognitive-search-settings-38864b","errorCode":null,"errorMessage":"Failed to create Azure Cognitive Search settings.","messagePattern":"Failed to create Azure Cognitive Search settings\\.","errorType":"exception","errorClass":"MemoryConnectorInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/azure_cognitive_search/azure_cognitive_search_memory_store.py","lineNumber":92,"sourceCode":"            azure_credentials (AzureKeyCredential | None): Azure Cognitive Search credentials (default: {None}).\n            token_credentials (TokenCredential | None): Azure Cognitive Search token credentials\n                (default: {None}).\n            env_file_path (str | None): Use the environment settings file as a fallback\n                to environment variables\n            env_file_encoding (str | None): The encoding of the environment settings file\n\n        \"\"\"\n        from semantic_kernel.connectors.azure_ai_search import AzureAISearchSettings\n\n        try:\n            acs_memory_settings = AzureAISearchSettings(\n                env_file_path=env_file_path,\n                endpoint=search_endpoint,\n                api_key=admin_key,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as exc:\n            raise MemoryConnectorInitializationError(\"Failed to create Azure Cognitive Search settings.\") from exc\n\n        self._vector_size = vector_size\n        self._search_index_client = get_search_index_async_client(\n            search_endpoint=str(acs_memory_settings.endpoint),\n            admin_key=acs_memory_settings.api_key.get_secret_value() if acs_memory_settings.api_key else None,\n            azure_credential=azure_credentials,\n            token_credential=token_credentials,\n        )\n\n    async def close(self):\n        \"\"\"Async close connection, invoked by MemoryStoreBase.__aexit__().\"\"\"\n        if self._search_index_client is not None:\n            await self._search_index_client.close()\n\n    async def create_collection(\n        self,\n        collection_name: str,\n        vector_config: HnswAlgorithmConfiguration | None = None,","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/azure_cognitive_search/azure_cognitive_search_memory_store.py#L74-L110","documentation":"Raised in the `AzureCognitiveSearchMemoryStore` constructor when building the pydantic `AzureAISearchSettings` raises a `ValidationError`; it is re-raised as `MemoryConnectorInitializationError` (chained via `from exc`). Required settings such as endpoint and api_key are missing or invalid. Note the message is static and does not echo the validation detail, so inspect the chained cause.","triggerScenarios":"Constructing `AzureCognitiveSearchMemoryStore(...)` without a search endpoint or admin key (neither as args nor from `AZURE_COGNITIVE_SEARCH_ENDPOINT` / `AZURE_COGNITIVE_SEARCH_ADMIN_KEY` env vars nor the `.env` file). Pydantic `ValidationError` -> wrapped exception.","commonSituations":"Missing `.env` or wrong `env_file_path`; env vars not set in the deployment; typo in env var name; passing an empty string; CI/container missing the ACS secrets.","solutions":["Set `AZURE_COGNITIVE_SEARCH_ENDPOINT` and `AZURE_COGNITIVE_SEARCH_ADMIN_KEY` env vars (or pass `search_endpoint`/`admin_key` args).","Point `env_file_path` at an existing `.env` file with correct values; verify `env_file_encoding`.","Inspect `exc.__cause__` (the wrapped `ValidationError`) for the exact missing fields.","Confirm secrets are present in the runtime environment (container/CI), not only locally."],"exampleFix":"// before\nstore = AzureCognitiveSearchMemoryStore(vector_size=1536)  # no endpoint/key\n\n// after\nstore = AzureCognitiveSearchMemoryStore(\n    search_endpoint=os.environ[\"AZURE_COGNITIVE_SEARCH_ENDPOINT\"],\n    admin_key=os.environ[\"AZURE_COGNITIVE_SEARCH_ADMIN_KEY\"],\n    vector_size=1536,\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef acs_env_ready() -> bool:\n    return bool(os.getenv(\"AZURE_COGNITIVE_SEARCH_ENDPOINT\")\n               and os.getenv(\"AZURE_COGNITIVE_SEARCH_ADMIN_KEY\"))\n\n# assert acs_env_ready() before constructing AzureCognitiveSearchMemoryStore","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import MemoryConnectorInitializationError\ntry:\n    store = AzureCognitiveSearchMemoryStore(...)\nexcept MemoryConnectorInitializationError as e:\n    cause = e.__cause__  # pydantic ValidationError\n    raise SystemExit(f\"ACS settings invalid: {cause}\") from e","preventionTips":["Set both `AZURE_COGNITIVE_SEARCH_ENDPOINT` and `AZURE_COGNITIVE_SEARCH_ADMIN_KEY` in env/`.env`.","Validate presence of both at startup before constructing the store.","Inspect the chained `ValidationError` for precise missing fields.","Inject secrets via CI/container secret variables, not committed files."],"tags":["azure-cognitive-search","settings","pydantic","validation","config","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}