{"record":{"id":"cd2f5cadf64eaa4f","repo":"microsoft/semantic-kernel","slug":"failed-to-create-azure-cognitive-search-settings","errorCode":null,"errorMessage":"Failed to create Azure Cognitive Search settings.","messagePattern":"Failed to create Azure Cognitive Search settings\\.","errorType":"exception","errorClass":"VectorStoreInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_ai_search.py","lineNumber":385,"sourceCode":"                search_endpoint=kwargs.get(\"search_endpoint\"),\n                search_credential=search_credential,\n                managed_search_index_client=False,\n                managed_client=False,\n                embedding_generator=embedding_generator,\n            )\n            return\n\n        if search_index_client:\n            try:\n                azure_ai_search_settings = AzureAISearchSettings(\n                    env_file_path=kwargs.get(\"env_file_path\"),\n                    endpoint=kwargs.get(\"search_endpoint\"),\n                    api_key=kwargs.get(\"api_key\"),\n                    env_file_encoding=kwargs.get(\"env_file_encoding\"),\n                    index_name=collection_name,\n                )\n            except ValidationError as exc:\n                raise VectorStoreInitializationException(\"Failed to create Azure Cognitive Search settings.\") from exc\n            endpoint = str(azure_ai_search_settings.endpoint)\n            credential = search_credential or _resolve_credential(\n                azure_ai_search_settings,\n                azure_credential=kwargs.get(\"azure_credentials\"),\n                token_credential=kwargs.get(\"token_credentials\"),\n            )\n            super().__init__(\n                record_type=record_type,\n                definition=definition,\n                collection_name=azure_ai_search_settings.index_name,\n                search_client=_get_search_client(\n                    endpoint=endpoint,\n                    collection_name=azure_ai_search_settings.index_name,\n                    credential=credential,\n                ),\n                search_index_client=search_index_client,\n                search_endpoint=endpoint,\n                search_credential=credential,","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_ai_search.py#L367-L403","documentation":"Raised in the AzureAISearchCollection constructor when a search_index_client is supplied (but no search_client) and constructing AzureAISearchSettings raises a pydantic ValidationError. Settings require a valid HTTPS endpoint (HttpsUrl) and, if index_name is involved, a non-empty name. The original ValidationError is chained via 'from exc'. The message still says 'Azure Cognitive Search' (the legacy product name).","triggerScenarios":"Instantiating AzureAISearchCollection(search_index_client=client, ...) where AZURE_AI_SEARCH_ENDPOINT is unset and no search_endpoint kwarg is given (endpoint is a required HttpsUrl field); or the endpoint string is not a valid HTTPS URL; or env_file_encoding is misconfigured causing the env file to fail to parse.","commonSituations":"Passing a pre-built SearchIndexClient but forgetting the endpoint because it was assumed to come from the client; a malformed endpoint URL; a .env file with the wrong encoding; running in CI without env vars injected.","solutions":["Pass search_endpoint='https://<svc>.search.windows.net' explicitly in kwargs, or set AZURE_AI_SEARCH_ENDPOINT.","Inspect the chained ValidationError (__cause__) for the exact failing field — it names whether endpoint, index_name, or encoding is at fault.","Ensure the endpoint scheme is https:// — HttpsUrl rejects http://.","If using a .env file, confirm env_file_path and env_file_encoding are correct and the file is readable."],"exampleFix":"// before\ncol = AzureAISearchCollection(\n    record_type=MyModel,\n    search_index_client=idx_client,  # endpoint missing\n)\n\n// after\ncol = AzureAISearchCollection(\n    record_type=MyModel,\n    search_index_client=idx_client,\n    search_endpoint=\"https://mysvc.search.windows.net\",\n)","handlingStrategy":"try-catch","validationCode":"import os\n\ndef ensure_endpoint_configured(**kwargs) -> str:\n    ep = kwargs.get(\"search_endpoint\") or os.getenv(\"AZURE_AI_SEARCH_ENDPOINT\")\n    if not ep or not ep.startswith(\"https://\"):\n        raise ValueError(\"Set search_endpoint or AZURE_AI_SEARCH_ENDPOINT to a valid https:// URL\")\n    return ep\n\nensure_endpoint_configured(search_index_client=idx_client)","typeGuard":null,"tryCatchPattern":"from pydantic import ValidationError\nfrom semantic_kernel.exceptions import VectorStoreInitializationException\ntry:\n    col = AzureAISearchCollection(record_type=M, search_index_client=idx)\nexcept VectorStoreInitializationException as e:\n    cause = e.__cause__\n    assert isinstance(cause, ValidationError)\n    # cause.errors() lists the failing field, e.g. endpoint required\n    raise","preventionTips":["Always pass search_endpoint when supplying only a search_index_client.","Read __cause__ (ValidationError.errors()) for the precise field at fault.","Keep a .env with AZURE_AI_SEARCH_ENDPOINT as a fallback."],"tags":["configuration","azure-ai-search","startup","settings"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}