According to your description, I checked this issue and tested it via the following approaches, you could refer to them:
#r "Newtonsoft.Json"
using System.Net;
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
public static HttpResponseMessage Run(HttpRequestMessage req,out object outputDocument,TraceWriter log)
{
dynamic doc = new
{
customer = "mycust",
version = "version2",
document = JObject.Parse("{\"prop1\": \"Some text.\"}")
};
outputDocument=doc;
return req.CreateResponse(HttpStatusCode.OK, "success");
}
Or refer to Azure WebJobs SDK Extensions for DocumentDB and configure as follows:
#r "Newtonsoft.Json"
using System.Net;
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Microsoft.Azure.WebJobs.Extensions.DocumentDB;
public static HttpResponseMessage Run(HttpRequestMessage req,[DocumentDB("brucedb-2", "todoitem",ConnectionStringSetting = "brucedocumentdb-01_DOCUMENTDB")] out object outputDocument,TraceWriter log)
{
dynamic doc = new
{
customer = "mycust",
version = "version2",
document = JObject.Parse("{\"prop1\": \"Some text.\"}")
};
outputDocument=doc;
return req.CreateResponse(HttpStatusCode.OK, "success");
}
Additionally, you could also leverage Microsoft Azure DocumentDB Client Library and refer to this similar issue for adding new document to Azure DocumentDB.