public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, methods: new string[] { "GET", "PUT", "OPTIONS" })] HttpRequestMessage req, TraceWriter log, [Inject(typeof(IMetadataApi))] IMetadataApi metadataApi) { var httpMethods = new Dictionary <string, Func <HttpRequestMessage, TraceWriter, Task <HttpResponseMessage> > > { { "GET", async(r, l) => await metadataApi.Get(r, l) }, { "PUT", async(r, l) => await metadataApi.Put(r, l) }, }; var response = httpMethods.ContainsKey(req.Method.Method) ? await httpMethods[req.Method.Method](req, log) : req.CreateResponse(req.Method.Method == "OPTIONS" ? HttpStatusCode.OK : HttpStatusCode.NotFound); AddCORSHeader(req, response, "GET, PUT, OPTIONS"); return(response); }