问题描述
我的逻辑应用程序从api其余部分收集数据,并将其插入cosmosdb mongodb中.该过程成功完成,但是使用Data Explorer执行查询时,发生以下错误:
My logic app collects data from an api rest and inserts into a cosmosdb mongodb. The process occurs successfully, but when performing a query using Data Explorer the following error occurs:
Error while fetching page of documents: {"code":400,"body":"Command find failed: Unknown server error occurred when processing this request."}
以下是重现错误的调用示例:
Here is an example of a call that reproduces the error:
"Create_or_update_document": {
"inputs": {
"body": {
"id": "11111",
"name": "john",
"surname": "doe"
},
"host": {
"connection": {
"name": "@parameters('$connections')['documentdb']['connectionId']"
}
},
"method": "post",
"path": "/dbs/@{encodeURIComponent('cockpit')}/colls/@{encodeURIComponent('target-collection')}/docs"
},
"runAfter": {
"HTTP_2": [
"Succeeded"
]
},
"type": "ApiConnection"
}
示例输入:
{
"id": "11111",
"name": "john",
"surname": "doe"
}
我一直在探索的是与ObjectId的创建有关的东西.有人知道解决方案吗?
What I've been exploring is something related to the creation of the ObjectId. Does anyone know a solution?
推荐答案
您现在不能将Azure Cosmos DB Logic Apps连接器与MongoDB API一起使用.目前,它在后台使用了SQL REST API.
You can't use the Azure Cosmos DB Logic Apps connector with the MongoDB API right now. It uses the SQL REST API under the hood at the moment.
我建议您创建一个简单的Azure函数,以您选择的语言从MongoDB驱动程序中为您完成插入,然后从Logic Apps中调用该函数.
I recommend you create a simple Azure Function that does the insert for you from a MongoDB Driver in your language of choice, then call that Function from Logic Apps.
这篇关于在Mongodb和Logic Apps中插入文档时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!