When POSTing (from Postman), I end up with duplicate documents with the same "_id". Looking at the examples here and here, I'm wondering if my issue is that something is not set up correcly in my Cosmos DB instance? Example:
if I update my shape's color to orange, I get another document with the key of 1 but what I'm expecting is to see a single document with the key of 1 with a shape that has the color orange.
Function:
public static void Run(
ILogger logger,
[EventGridTrigger] EventGridEvent e,
[CosmosDB(
databaseName: "myDatabase",
collectionName: "myCollection",
ConnectionStringSetting = "COSMOS_CONNECTION_STRING")] out MyObject myObjectDocument
)
{
logger.LogInformation("Event received {type} {subject}", e.EventType, e.Subject);
myObjectDocument = JsonConvert.DeserializeObject<MyObject>(e.Data.ToString());
logger.LogInformation(myObjectDocument.some.thing);
}
Payload:
[
{
"topic": "Topic",
"id": "1",
"eventType": "EventType",
"subject": "Subject",
"eventTime": "2012-08-10T21:04:07+00:00",
"data" : {
"id" : 1,
"effectiveDate" : "2020-10-18 15:00:00",
"shape" : {
"_id" : "1000",
"color" : "green",
"name" : "square"
}
},
"dataVersion": "2.0",
"metadataVersion": "1"
}
]
Edits:
Partition Key is "id"
Matias Quaranta's answer and comments did the trick. Note also the partition key must be a string
and not an int