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
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.