title: Dotnet-Isolated Azure Functions - how to access HttpContext
body: <p>I have a dotnet 5 Azure Function (dotnet-isolated) that is triggered by an HTTP call.</p>
  <p>The function will be called by a different Azure function app and I'd like to secure the target with Azure AD and use &quot;client-credentations&quot; OAuth2 flow.</p>
  <p>I found an excellent sample that informs for my scenario at: Microsoft GitHub Sample</p>
  <p>My problem is, the sample uses a WebApi app as the service. This has access to the HttpContext object uses an extension method in the Microsft.Identity.Web assembly called &quot;ValidateAppRole&quot;</p>
  <p>My Azure function does have a parameter of type HttpRequestData. This has a headers property containing key value pairs. One of those keys is called &quot;Authorization&quot; and its value is the Access Token provided by Azure AD. I've run this token through jwt.ms and can confirm that the &quot;Roles&quot; collection contains the custom role I need to validate. So I know the information required is present; I just don't know how to check for it programmatically.</p>
  <p>Since a dotnet-isolated Azure function doesn't seem to have access to the HttpContext object. How can a check equivalent to the following be made?</p>
  <pre><code>HttpContext.ValidateAppRole(&quot;CustomRoleName&quot;);
  </code></pre>