public async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest request, ILogger logger) { if (request is null) { logger.LogError(CommentResources.ParameterCannotBeNull, nameof(request)); return(new BadRequestResult()); } try { var form = await request.ReadFormAsync().ConfigureAwait(false); var result = await _postCommentService.PostCommentAsync(form).ConfigureAwait(false); switch (result.HttpStatusCode) { case HttpStatusCode.OK: return(new OkResult()); case HttpStatusCode.Redirect: return(new RedirectResult(result.RedirectUrl?.AbsoluteUri)); default: logger.LogError(result.Exception, result.Error); return(new BadRequestResult()); } } catch (Exception e) { logger.LogError(e, CommentResources.PostCommentExceptionMessage, e.Message); throw; } }