title: How to get current user identity in Azure Function with Azure Authentication?
body: <p>I have created a new Function App, enabled App Service Authentication / Authorization for it ("<em>Use Authentication / Authorization to protect your application and work with per-user data</em>") and disabled non-authenticated requests.</p>
  
  <p>Everything seems to be working correctly so far. If I try to request my <code>HttpTrigger</code>ed function, it requires me to log in first; once I'm logged in, all requests are processed as they should be. So there is no problem with "protect your application" part.</p>
  
  <p>However, I'm totally stuck with the "work with per-user data" part. My Azure Function is invoked as</p>
  
  <pre><code>public static async Task&lt;HttpResponseMessage&gt; Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]HttpRequestMessage req, TraceWriter log)
  </code></pre>
  
  <p>And there is nothing related to authentication in <code>HttpRequestMessage</code>. (AuthorizationLevel.Anonymous seems to control the entirely different thing - namely, if the function could be called by anyone or only by those who have a fixed API key).</p>
  
  <p>How do I get the identity of authenticated user who called the function?</p>