microsoft/semantic-kernel · error · MemoryConnectorInitializationError
Failed to create Azure Cognitive Search settings.
Error message
Failed to create Azure Cognitive Search settings.
What it means
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.
Source
Thrown at python/semantic_kernel/connectors/memory_stores/azure_cognitive_search/azure_cognitive_search_memory_store.py:92
azure_credentials (AzureKeyCredential | None): Azure Cognitive Search credentials (default: {None}).
token_credentials (TokenCredential | None): Azure Cognitive Search token credentials
(default: {None}).
env_file_path (str | None): Use the environment settings file as a fallback
to environment variables
env_file_encoding (str | None): The encoding of the environment settings file
"""
from semantic_kernel.connectors.azure_ai_search import AzureAISearchSettings
try:
acs_memory_settings = AzureAISearchSettings(
env_file_path=env_file_path,
endpoint=search_endpoint,
api_key=admin_key,
env_file_encoding=env_file_encoding,
)
except ValidationError as exc:
raise MemoryConnectorInitializationError("Failed to create Azure Cognitive Search settings.") from exc
self._vector_size = vector_size
self._search_index_client = get_search_index_async_client(
search_endpoint=str(acs_memory_settings.endpoint),
admin_key=acs_memory_settings.api_key.get_secret_value() if acs_memory_settings.api_key else None,
azure_credential=azure_credentials,
token_credential=token_credentials,
)
async def close(self):
"""Async close connection, invoked by MemoryStoreBase.__aexit__()."""
if self._search_index_client is not None:
await self._search_index_client.close()
async def create_collection(
self,
collection_name: str,
vector_config: HnswAlgorithmConfiguration | None = None,View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before
store = AzureCognitiveSearchMemoryStore(vector_size=1536) # no endpoint/key
// after
store = AzureCognitiveSearchMemoryStore(
search_endpoint=os.environ["AZURE_COGNITIVE_SEARCH_ENDPOINT"],
admin_key=os.environ["AZURE_COGNITIVE_SEARCH_ADMIN_KEY"],
vector_size=1536,
) Defensive patterns
Strategy: validation
Validate before calling
import os
def acs_env_ready() -> bool:
return bool(os.getenv("AZURE_COGNITIVE_SEARCH_ENDPOINT")
and os.getenv("AZURE_COGNITIVE_SEARCH_ADMIN_KEY"))
# assert acs_env_ready() before constructing AzureCognitiveSearchMemoryStore Try / catch
from semantic_kernel.exceptions import MemoryConnectorInitializationError
try:
store = AzureCognitiveSearchMemoryStore(...)
except MemoryConnectorInitializationError as e:
cause = e.__cause__ # pydantic ValidationError
raise SystemExit(f"ACS settings invalid: {cause}") from e Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to create AstraDB settings.
- Failed to create Azure OpenAI settings: {exc}
- Failed to validate Google AI settings: {e}
- Failed to validate Google AI settings: {e}
- Invalid settings: {exc}
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/38864b292ff6c707.
Report an issue: GitHub.