Problems inserting document with Mongodb and Logic Apps

扶醉桌前 提交于 2019-12-11 07:57:54

问题


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"
            }

Example input:

{
  "id": "11111",
  "name": "john",
  "surname": "doe"
}

What I've been exploring is something related to the creation of the ObjectId. Does anyone know a solution?


回答1:


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.

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.




回答2:


Based on the Connectors for Azure Logic Apps document,you could find the ~200+ connectors list.

Then navigate to the Azure Cosmos DB Connector, you could see the statement:

To use this integration, you will need a Cosmos DB SQL API account configured in the Azure Portal. Note that Mongo DB API accounts are not currently supported.



来源:https://stackoverflow.com/questions/54368112/problems-inserting-document-with-mongodb-and-logic-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!