title: Adding custom headers to Azure Functions response
body: <p>I'm working on an Azure Function App (v2), which has a number of different functions inside the same Function App.</p>
  
  <p>It is going to be deployed in multiple Azure regions, and I would like to add a custom header, that indicates which region served the request.</p>
  
  <p>I know that I can let each function return <code>HttpResponseMessage</code> which can contain custom headers. Instead of duplicating that code to each function, I would like to make it centralized in the entire Function App project. Another drawback of returning <code>HttpResponseMessage</code> is that I would like to use <code>IActionResult</code>, so I can use <code>JsonResult</code> or <code>OkObjectResult</code> and similar return types.</p>
  
  <p>With an ASP.NET MVC project, I could add a middleware which added the header or add the headers using <code>web.config</code>. Neither seems to be possible in a Function App.</p>
  
  <p>How can this be done without having to return <code>HttpResponseMessage</code> and adding the header inside each function's <code>Run</code> method?</p>