目前,我可以通过Postman通过HTTP请求创建数据源和索引。我的 Azure AI 搜索和 CosmosDB for Mongo 都已禁用公共访问。
我的数据源的 POST 请求有效:
POST https://example-mongo.search.windows.net/datasources?api-version=2024-07-01
Content-Type: application/json
api-key: [my key for azure search]
{
"name" : "collection-datasource",
"description" : "Anything you want, or nothing at all",
"type" : "cosmosdb",
"credentials" : {
"connectionString" : "AccountEndpoint=https://example-mongo.documents.azure.com:443/;AccountKey=abcd==;Database=DB;ApiKind=MongoDB"
},
"container": {
"name": "collection"
}
}
索引器的 POST 请求不起作用并给我一个 403 错误:
POST https://example-mongo.search.windows.net/indexers?api-version=2024-07-01
Content-Type: application/json
api-key: [my key for azure search]
{
"name": "collection-indexer",
"description": null,
"dataSourceName": "collection-datasource",
"targetIndexName": "collection-index", #Created previously through postman as well
"parameters": {
"batchSize": null,
"maxFailedItems": null,
"maxFailedItemsPerBatch": null
},
"fieldMappings": [
{
"sourceFieldName": "productDescription",
"targetFieldName": "productDescriptionCustom",
"mappingFunction": null
}
]
}
403错误:
Error with data source: Response status code does not indicate success: Forbidden (403);
Substatus: 0; ActivityId: 1ffa970a-5bb7-42fa-8ace-968fc329bae1;
Reason: (Request originated from IP --- through public internet.
This is blocked by your Cosmos DB account firewall settings.
More info: https://aka.ms/cosmosdb-tsg-forbidden\r\nActivityId: --,
Microsoft.Azure.Documents.Common/2.14.0, Windows/10.0.20348 cosmos-netstandard-sdk/3.30.20);
Please adjust your data source definition in order to proceed
当我尝试使用现有索引和数据源通过门户创建索引器时,会发生同样的错误。
我不确定“请调整您的数据源定义”是什么意思。我是否能够以某种方式将 CosmosDB 的连接字符串添加到创建索引器的请求中?或者还有其他问题需要我解决吗?
首先,配置 Cosmos DB 帐户防火墙设置以允许从 Azure 认知搜索进行访问。通过此操作,我们可以将 Azure 认知搜索的 IP 范围或服务标记添加到 Cosmos DB 防火墙。