Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Function - Webhook to enqueue a message
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
[Queue("changevmstate")] out string state,
ILogger log)
state = null;
string requestBody = new StreamReader(req.Body).ReadToEnd();
var data = JsonConvert.DeserializeObject<Request>(requestBody);
var query= data.queryResult.queryText;
dynamic actionResult = new ExpandoObject();
string result = string.Empty;
if (data.queryResult.intent.displayName == "ChangeVMState")
state = data.queryResult.parameters.vmstate;
result = $"{state} is going to be applied, Irwin";
actionResult.fulfillmentText = result;
actionResult.source = botId;
var output = JsonConvert.SerializeObject(actionResult,
Formatting.Indented, new AtAtJsonConverter(typeof(ExpandoObject)));
return output != null
? (ActionResult)new JsonResult(actionResult)
: new BadRequestObjectResult("ERROR: "+output);
catch (Exception ex)
log.LogError(ex, ex.Message);
return new BadRequestObjectResult("Badness");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment