Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kasunkv

kasunkv/run.csx Secret

Created June 25, 2017 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasunkv/ed792357aacb7dd87131ed21317cea06 to your computer and use it in GitHub Desktop.
Save kasunkv/ed792357aacb7dd87131ed21317cea06 to your computer and use it in GitHub Desktop.
Azure Functions: ReceiveNotification Function final state.
#r "Newtonsoft.Json"
using System;
using System.Net;
using Newtonsoft.Json;
public static async Task<object> Run(HttpRequestMessage req, TraceWriter log, IAsyncCollector<Notification> outputItem)
{
log.Info($"Notification Received.");
string jsonContent = await req.Content.ReadAsStringAsync();
var notification = JsonConvert.DeserializeObject<Notification>(jsonContent);
await outputItem.AddAsync(notification);
return req.CreateResponse(HttpStatusCode.OK, new
{
message = $"Notification Request Received From: {notification.Email}"
});
}
public class Notification {
public string NotificationId { get; set; }
public string Email { get; set; }
public string Subject { get; set; }
public string Content { get; set; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment