title: Azure Functions V2 Deserialize HttpRequest as object
body: <p>I'm surprised I can't find the answer to this but I've got an Azure function (HTTP Trigger) I simply want to deserialize the content as an object. Previously with V1 I was able to do this,</p>
  
  <p><strong>Functions V1</strong></p>
  
  <pre><code>[FunctionName("RequestFunction")]
  public static async Task&lt;HttpResponseMessage&gt; Run([HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]HttpRequestMessage req, TraceWriter log)
  {
      // Successful deserialization of the content
      var accountEvent = await req.Content.ReadAsAsync&lt;AccountEventDTO&gt;();
  
      // Rest of the function...
  }
  </code></pre>
  
  <p>But now with V2 it looks more like this,</p>
  
  <p><strong>Functions V2</strong></p>
  
  <pre><code>[FunctionName("RequestFunction")]
  public static async Task&lt;IActionResult&gt; Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)]HttpRequest req, ILogger log)
  {
      // Content doesn't exist on HttpRequest anymore so this line doesn't compile
      var accountEvent = await req.Content.ReadAsAsync&lt;AccountEventDTO&gt;();
  
      // Rest of the function...
  }
  </code></pre>
  
  <p>I can get the body to access the stream from the HttpRequest object but am unsure how I would cast that to the expected object. Any ideas?</p>