Azure Function with Cosmos MongoDB integration not saving

后端 未结 1 2064
有刺的猬
有刺的猬 2020-12-22 04:21

I have setup a Azure Function with a Azure Cosmos DB(document) output. The cosmos database is configured to be a MongoDB. And added the following simple code to try and add

相关标签:
1条回答
  • 2020-12-22 04:48

    The DocumentDB output binding is using the DocumentDB API to connect and save information in the database. But your database (from what you are saying) is using the MongoDB API, they are different APIs (links point to the docs).

    As you surely know, MongoDB has some requirements (like the existence of an "_id" attribute) that are covered when you connect to the database from a MongoDB client (either an SDK or a third-party client), but since you are communicating through the DocumentDB API, it's probably failing to fulfill those requirements.

    You might want to try and use the Mongo driver in the function to connect to your Cosmos DB database through the MongoDB API.

    0 讨论(0)
提交回复
热议问题