Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#r "Newtonsoft.Json"
#r "System.Configuration"
using System;
using System.Configuration;
using System.Net;
using Newtonsoft.Json;
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log)
{
log.Verbose($"Webhook was triggered!");
var appKey = "FooKey";
var appValue = ConfigurationManager.AppSettings[appKey];
log.Verbose($"App Setting. Key : {appKey}, Value : {appValue}");
string jsonContent = await req.Content.ReadAsStringAsync();
dynamic data = JsonConvert.DeserializeObject(jsonContent);
if (data.first == null || data.last == null) {
return req.CreateResponse(HttpStatusCode.BadRequest, new {
error = "Please pass first/last properties in the input object"
});
}
return req.CreateResponse(HttpStatusCode.OK, new {
greeting = $"Hello {data.first} {data.last}!"
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment