Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CloudEvents validation with Azure Functions
public static class TestFuncApi
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "post", "options", Route = null)] HttpRequest req,
ILogger log)
if (req.Method == "OPTIONS")
// Retrieve the request origin
if (!req.Headers.TryGetValue("WebHook-Request-Origin", out var headerValues))
return new BadRequestObjectResult("Not a valid request");
// Respond with the origin and rate
var webhookRequestOrigin = headerValues.FirstOrDefault();
req.HttpContext.Response.Headers.Add("WebHook-Allowed-Rate", "*");
req.HttpContext.Response.Headers.Add("WebHook-Allowed-Origin", webhookRequestOrigin);
return new OkResult();
// Process event notifications
// Do something here....
return new OkObjectResult("OK");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment