Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// full repo at
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
log.Info("Webhook was triggered!");
string jsonContent = await req.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent);
if (data.Payload?.Event?.Message == null) {
return req.CreateResponse(HttpStatusCode.BadRequest, new {
error = "Payload.Event.Message missing from body."
var message = data.Payload.Event.Message;
var occurred = data.Payload.Event.Occurred;
log.Info("* " + message);
log.Info("* " + occurred);
// make call to Teams WebHook Url, which is stored in the app settings
var appKey = "TeamsWebHookUrl";
var webHookUrl = ConfigurationManager.AppSettings[appKey];
log.Info($"App Setting. {appKey}: {webHookUrl}");
// Payload content at
var body = new { text = $"{message} {occurred}" };
using (var client = new HttpClient())
await client.PostAsJsonAsync(webHookUrl, body);
log.Info("Sent the JSON payload to Teams WebHook!");
return req.CreateResponse(HttpStatusCode.OK);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.