I'm trying to build an Azure function in C# that creates a new document object in Azure cosmos DB using SQL API if an id doesn't already exist and updates a document object if it already exists.
The context behind this is logging chatbot conversation history to unique user sessions.
Input:
HTTP GET Request with parameters (id (string), chatHistory(string) and chatDateTime(string))
Output:
If document object with same id already exists - then update document with input chatHisotry and chatDateTime.
If no document object exists with same id then create a new document object with id, chatHistory and chatDateTime equal to input.
Any help much appreciated! Been struggling with this one for days.
Example of document object:
{
"id": "ESCRfAKwlTbH8W5aVRLxgA",
"chatHistory": "Hi, Hello",
"chatDateTime": "Fri Sep 21 2018 05:34:35 GMT+0000 (Coordinated Universal Time)",
"_rid": "RwYSAIqaSVg2AAAAAAAAAA==",
"_self": "dbs/RwYSAA==/colls/RwYSAIqaSVg=/docs/RwYSAIqaSVg2AAAAAAAAAA==/",
"_etag": "\"00007400-0000-0000-0000-5ba482ed0000\"",
"_attachments": "attachments/",
"_ts": 1537508077
}