title: Is it possible to run code before every function starts running in Azure Functions?
body: <p>Currently, I'm executing a bunch of code (such as validating query/header parameters as well as authenticating the user) in every function manually:</p>
  
  <pre><code>[FunctionName( "functionname" )]
  public static async Task&lt;HttpResponseMessage&gt; Run( [HttpTrigger( AuthorizationLevel.Anonymous, "post")]HttpRequestMessage req)
  {
  
     // Step 1 - Validate input
  
     // Step 2 - Process request
  
  }
  </code></pre>
  
  <p>But I'd like to refactor Step 1 out so that it doesn't appear inside each function.  Is it possible to write an attribute or some kind of pre-request logic that takes the <code>HttpRequestMessage</code> and returns a <code>HttpResponseMessage</code> (such as <code>BadRequest</code>)  based on validation outcome?</p>