This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@section scripts { | |
<script src="~/lib/signalr.min.js" type="text/javascript"></script> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/default.min.css"> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script> | |
<script>hljs.initHighlightingOnLoad();</script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.js"></script> | |
<script type="text/javascript"> | |
var hubConnection; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Newtonsoft.Json; | |
namespace CloudEventSample.Models | |
{ | |
public class CloudEvent<T> where T : class | |
{ | |
[JsonProperty("eventID")] | |
public string EventId { get; set; } | |
[JsonProperty("cloudEventsVersion")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
namespace CloudEventSample.Models | |
{ | |
public class Band | |
{ | |
public string Name { get; set; } | |
public List<Album> Albums { get; set; } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Net.Http; | |
using System.Net.Http.Headers; | |
using System.Text; | |
using System.Threading.Tasks; | |
using CloudEventSample.Models; | |
using Newtonsoft.Json; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cloudEvent = new CloudEvent<Band> | |
{ | |
EventId = Guid.NewGuid().ToString(), | |
EventType = "newBand", | |
EventTypeVersion = "1.0", | |
CloudEventVersion = "0.1", | |
Data = GetBand(), | |
Source = $"{Topic}#subjectband", | |
EventTime = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture), | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class NewBand | |
{ | |
[FunctionName("newband")] | |
public static IActionResult Run( | |
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)]HttpRequest req, | |
TraceWriter log) | |
{ | |
log.Info("newband function triggered"); | |
var requestBody = new StreamReader(req.Body).ReadToEnd(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<policies> | |
<inbound> | |
<base /> | |
<!-- Check event type --> | |
<set-variable value="@(context.Request.Headers["Aeg-Event-Type"].Contains("SubscriptionValidation"))" name="isEventGridSubscriptionValidation" /> | |
<set-variable value="@(context.Request.Headers["Aeg-Event-Type"].Contains("Notification"))" name="isEventGridNotification" /> | |
<choose> | |
<when condition="@(context.Variables.GetValueOrDefault<bool>("isEventGridSubscriptionValidation"))"> | |
<return-response> | |
<set-status code="200" reason="OK" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<set-variable value="@(context.Request.Headers["Aeg-Event-Type"].Contains("SubscriptionValidation"))" name="isEventGridSubscriptionValidation" /> | |
<set-variable value="@(context.Request.Headers["Aeg-Event-Type"].Contains("Notification"))" name="isEventGridNotification" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<choose> | |
<when condition="@(context.Variables.GetValueOrDefault<bool>("isEventGridSubscriptionValidation"))"> | |
<!-- handle subscription validation --> | |
</when> | |
<when condition="@(context.Variables.GetValueOrDefault<bool>("isEventGridNotification"))"> | |
<!-- handle notification message --> | |
</when> | |
</choose> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<when condition="@(context.Variables.GetValueOrDefault<bool>("isEventGridSubscriptionValidation"))"> | |
<return-response> | |
<set-status code="200" reason="OK" /> | |
<set-body>@{ | |
var events = context.Request.Body.As<string>(); | |
JArray a = JArray.Parse(events); | |
var eventGridData = a.First["data"]; | |
var validationCode = eventGridData["validationCode"]; | |
var jOutput = | |
new JObject( |