Skip to content

Instantly share code, notes, and snippets.

@MirzaMerdovic
Last active July 3, 2022 20:06
Show Gist options
  • Save MirzaMerdovic/67a5daca81076c9ce4627d04c05137bd to your computer and use it in GitHub Desktop.
Save MirzaMerdovic/67a5daca81076c9ce4627d04c05137bd to your computer and use it in GitHub Desktop.
Snippet for: Azure App Configuration as a configuration provider in .NET Core apps - Part 3: Hot-Reload (https://medium.com/p/de398e009553)
app.MapPost(
"/refresh",
async (
[FromBody] Azure.Messaging.EventGrid.EventGridEvent[] request,
[FromServices] IConfigurationRefresherProvider refreshProvider) =>
{
var eg = request.First();
if (eg.EventType == "Microsoft.EventGrid.SubscriptionValidationEvent")
{
var data = eg.Data.ToObjectFromJson<JsonObject>();
var responseData = new SubscriptionValidationResponse()
{
ValidationResponse = data["validationCode"].ToString()
};
return Results.Ok(responseData);
}
eg.TryCreatePushNotification(out var notification);
if (notification == null)
return Results.Ok();
foreach (var refresher in refreshProvider.Refreshers)
{
refresher.ProcessPushNotification(notification, TimeSpan.FromSeconds(1));
}
return Results.Ok();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment