EDITED with my own progress.
I am trying to use DocumentDb within an Azure Function that I am writing with the new Visual Studio Tooling which allows me to build and deploy a dll. My function.json file is created by the tooling so I don't think I can create my binding in function.json I have to use Attributes.
I have added the Microsoft.Azure.Webjobs.Extensions.DocumentDB package to my solution. I then have a function signature:
public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]
HttpRequestMessage req,
[DocumentDB("database", "collection"ConnectionStringSetting = "conn", Id = "w", PartitionKey = "customer")) DocumentClient docdbcli,
TraceWriter log)
In method body I have:
await docdbcli.CreateDocumentAsync(UriFactory.CreateDocumentCollectionUri("customerdocumentversionsdb", "snapshots"), new
{
id = "edse",
customer = "expedia",
document = Converter.Serialize(jliff),
version = "sourceedited"
});
The function.json compiled by the tooling is:
{
"bindings": [
{
"type": "httpTrigger",
"methods": [
"get",
"post"
],
"authLevel": "function",
"direction": "in",
"name": "req"
},
{
"type": "documentDB",
"databaseName": "customerdocumentversionsdb",
"collectionName": "snapshots",
"createIfNotExists": false,
"connection": "conn",
"id": "w",
"partitionKey": "customer",
"direction": "out",
"name": "docdbcli"
},
{
"name": "$return",
"type": "http",
"direction": "out"
}
],
"disabled": false,
"scriptFile": "..\\MtWithRulesFunctionApp.dll",
"entryPoint": "MtWithRulesFunctionApp.PreEditSource.Run"
}
My documents are not written to the db probably because the binding about is specified as out.