Azure AI Foundry添加Agent知识库时搜索索引加载失败(400错误)
向Agent添加知识库时遇到400错误:无法加载搜索服务索引
Unable to load search service indexes Request failed with status code 400.
当前环境状态
- Azure AI Search已与项目关联
- 已配置所需权限
- 可在搜索服务中执行搜索操作
索引创建方式
使用Terraform通过REST API创建了搜索索引、技能集和索引器,相关代码如下:
# Create Azure AI Search Index resource "null_resource" "create_search_index" { triggers = { search_service = azurerm_search_service.example.id } provisioner "local-exec" { command = <<EOT # Create index definition JSON cat > index.json <<EOF { "name": "cities-index", "fields": [ { "name": "chunk_id", "type": "Edm.String", "key": true, "analyzer": "keyword", "searchable": true, "sortable": true, "filterable": false, "facetable": false }, { "name": "parent_id", "type": "Edm.String", "filterable": true, "searchable": false, "sortable": false, "facetable": false }, { "name": "chunk", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false }, { "name": "title", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false }, { "name": "text_vector", "type": "Collection(Edm.Single)", "searchable": true, "retrievable": true, "filterable": false, "sortable": false, "facetable": false, "stored": true, "vectorSearchProfile": "cities-index-text-profile", "dimensions": 1536 }, { "name": "metadata_storage_path", "type": "Edm.String", "searchable": true, "filterable": false, "retrievable": false, "stored": true, "sortable": false, "facetable": false, "key": false } ], "vectorSearch": { "profiles": [ { "name": "cities-index-text-profile", "algorithm": "cities-index-algorithm", "vectorizer": "cities-index-text-vectorizer" } ], "algorithms": [ { "kind": "hnsw", "name": "cities-index-algorithm" } ], "vectorizers": [ { "kind": "azureOpenAI", "azureOpenAIParameters": { "resourceUri": "https://${azurerm_ai_services.example.name}.openai.azure.com/", "deploymentId": "text-embedding-ada-002", "modelName": "text-embedding-ada-002", "apiKey": "${azurerm_ai_services.example.primary_access_key}" }, "name": "cities-index-text-vectorizer" } ], "compressions": [] }, "semantic": { "defaultConfiguration": "cities-index-semantic-configuration", "configurations": [ { "name": "cities-index-semantic-configuration", "prioritizedFields": { "titleField": { "fieldName": "title" }, "prioritizedContentFields": [ { "fieldName": "chunk" } ] } } ] } } EOF # Create index using POST method curl -X POST \ -H "Content-Type: application/json" \ -H "api-key: ${azurerm_search_service.example.primary_key}" \ -d @index.json \ "https://${azurerm_search_service.example.name}.search.windows.net/indexes?api-version=2025-05-01-preview" EOT interpreter = ["bash", "-c"] } depends_on = [ azurerm_search_service.example ] } # Create Azure AI Search Skillset resource "null_resource" "create_search_skillset" { triggers = { search_service = azurerm_search_service.example.id } provisioner "local-exec" { command = <<EOT # Create skillset definition JSON cat > skillset.json <<EOF { "name": "cities-skillset", "description": "Skillset to chunk documents and generate embeddings", "skills": [ { "@odata.type": "#Microsoft.Skills.Text.SplitSkill", "description": "Split skill to chunk documents", "textSplitMode": "pages", "maximumPageLength": 2000, "pageOverlapLength": 500, "context": "/document", "inputs": [ { "name": "text", "source": "/document/content" } ], "outputs": [ { "name": "textItems", "targetName": "pages" } ] }, { "@odata.type": "#Microsoft.Skills.Text.AzureOpenAIEmbeddingSkill", "context": "/document/pages/*", "inputs": [ { "name": "text", "source": "/document/pages/*" } ], "outputs": [ { "name": "embedding", "targetName": "text_vector" } ], "resourceUri": "https://${azurerm_ai_services.example.name}.openai.azure.com/", "deploymentId": "text-embedding-ada-002", "modelName": "text-embedding-ada-002", "apiKey": "${azurerm_ai_services.example.primary_access_key}", "dimensions": 1536 } ], "indexProjections": { "selectors": [ { "targetIndexName": "cities-index", "parentKeyFieldName": "parent_id", "sourceContext": "/document/pages/*", "mappings": [ { "name": "title", "source": "/document/title" }, { "name": "chunk", "source": "/document/pages/*" }, { "name": "text_vector", "source": "/document/pages/*/text_vector" }, { "name": "metadata_storage_path", "source": "/document/metadata_storage_path", "inputs": [] } ] } ], "parameters": { "projectionMode": "skipIndexingParentDocuments" } } } EOF # Create skillset using POST method curl -X POST \ -H "Content-Type: application/json" \ -H "api-key: ${azurerm_search_service.example.primary_key}" \ -d @skillset.json \ "https://${azurerm_search_service.example.name}.search.windows.net/skillsets?api-version=2025-05-01-preview" EOT interpreter = ["bash", "-c"] } depends_on = [ azurerm_search_service.example, azurerm_ai_services.example ] } # Create Azure AI Search Indexer resource "null_resource" "create_search_indexer" { triggers = { search_service = azurerm_search_service.example.id } provisioner "local-exec" { command = <<EOT # Create indexer definition JSON cat > indexer.json <<EOF { "name": "cities-indexer", "targetIndexName": "cities-index", "dataSourceName": "azureblob-1752751172828-datasource", "skillsetName": "cities-skillset", "schedule": null, "fieldMappings": [ { "sourceFieldName": "metadata_storage_name", "targetFieldName": "title" } ], "parameters": { "configuration": { "dataToExtract": "contentAndMetadata", "parsingMode": "default" } } } EOF # Create indexer using POST method curl -X POST \ -H "Content-Type: application/json" \ -H "api-key: ${azurerm_search_service.example.primary_key}" \ -d @indexer.json \ "https://${azurerm_search_service.example.name}.search.windows.net/indexers?api-version=2025-05-01-preview" EOT interpreter = ["bash", "-c"] } depends_on = [ null_resource.create_search_datasource, null_resource.create_search_index, null_resource.create_search_skillset ] }
内容的提问来源于stack exchange,提问作者One Developer
相关产品推荐
相关产品推荐

