public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, ILogger log, ExecutionContext context) { log.LogInformation($"C# HTTP trigger function processed this request: {req}"); WebhookRequest input = await req.Content.ReadAsAsync <WebhookRequest>(); if (input == null) { return(req.CreateResponse(HttpStatusCode.NotFound)); } // If the Url parameter only contains whitespaces or is empty return with BadRequest. if (string.IsNullOrWhiteSpace(input.Url)) { return(req.CreateErrorResponse(HttpStatusCode.BadRequest, "The url parameter can not be empty.")); } // Validates if input.url is a valid aboslute url, aka is a complete refrence to the resource, ex: http(s)://google.com if (!Uri.IsWellFormedUriString(input.Url, UriKind.Absolute)) { return(req.CreateErrorResponse(HttpStatusCode.BadRequest, $"{input.Url} is not a valid absolute Url. The Url parameter must start with 'http://' or 'http://'.")); } WebhookResponse response = new WebhookResponse { Url = input.Url }; var config = new ConfigurationBuilder() .SetBasePath(context.FunctionAppDirectory) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables() .Build(); StorageTableHelper stgHelper = new StorageTableHelper(config["UlsDataStorage"]); try { await stgHelper.SaveWebhookEntity(new WebhookEntity(input.Url)); } catch (Exception ex) { log.LogError(ex, "An unexpected error was encountered."); return(req.CreateResponse(HttpStatusCode.BadRequest, ex)); } return(req.CreateResponse(HttpStatusCode.OK, response)); }