public Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req) { _logger.LogInformation($"{nameof(ProductsFunction)} trigger function processed a request."); var sku = string.IsNullOrEmpty(req.Query["sku"]) ? (int?)null : Convert.ToInt32(req.Query["sku"]); var policyWrap = Policy.Wrap(_latencyPolicy, _faultPolicy); var outcome = policyWrap.ExecuteAndCapture(() => _backend.GetProducts(sku)); switch (outcome.FinalException == null) { default: return(Task.FromResult <IActionResult>(new OkObjectResult(outcome.Result))); case false: _logger.LogException(outcome.FinalException); return(Task.FromResult <IActionResult>(new BadRequestObjectResult(outcome.FinalException))); } }