title: Azure Functions Update DocumentDb document with Binder
body: <p>A follow-question to my <a href="https://stackoverflow.com/questions/42003600/azure-iot-hub-eventhub-and-functions">previous post</a> about Azure Functions. I need to update a document in DocumentDB using the imperative binder (Binder). I don't really understand the <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#advanced-binding-at-runtime-imperative-binding" rel="nofollow noreferrer">documentation</a> and I can't find any examples (I more or less find one kind of example which is the TextWriter one). The documentation says I can bind to "out T" by I find no examples of this.</p>
  
  <p>Say that the document looks like this before running the function: </p>
  
  <pre><code>{
      child: {
          value: 0
      }
  }
  </code></pre>
  
  <p>And the functions looks like this:</p>
  
  <pre><code>var document = await binder.BindAsync&lt;dynamic&gt;(new DocumentDBAttribute("myDB", "myCollection")
  {
      ConnectionStringSetting = "my_DOCUMENTDB",
      Id = deviceId
  });
  
  log.Info($"C# Event Hub trigger function processed a message: document: { document }");
  
  document.value = 100;
  document.child.value = 200;
  
  log.Info($"Updated document: { document }");
  </code></pre>
  
  <p>According to the second logging row, the document isn't properly updated. The child is not updated (which existed when read from the store) and value is added. Either way, nothing is persisted. I've tried adding an Output in the function.json, but the compiler complains about it and the documentation states that you shouldn't have any.</p>
  
  <p>What am I missing?</p>