public async Task <IActionResult> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "customers/find/{id}")] HttpRequest request, int id, ILogger logger) { logger.LogInformation($"Invoked {nameof(GetCustomerFunction)}"); var userInformation = _securityHandler.To <AllowedFeatureCollection>(request, FeatureConstants.AllowedFeaturesClaim); if (userInformation?.Features == null || !userInformation.Features.Any()) { return(new StatusCodeResult((int)HttpStatusCode.Unauthorized)); } var hasAccess = userInformation.Features.FirstOrDefault(x => x.FeatureId == FeatureConstants.Customers) != null; if (!hasAccess) { return(new StatusCodeResult((int)HttpStatusCode.Unauthorized)); } var customer = await _queryHandler.HandleAsync(new GetCustomerByIdQuery(id)); if (customer == null) { logger.LogWarning($"Customer not found: {id}"); return(new NotFoundResult()); } var data = new { customer.Id, customer.Name, customer.Address }; return(new OkObjectResult(data)); }