Skip to content

Instantly share code, notes, and snippets.

@jeffhollan
Created February 8, 2018 19:10
Show Gist options
  • Save jeffhollan/2d514e0e1a0b9195f5d2553fdc04cf78 to your computer and use it in GitHub Desktop.
Save jeffhollan/2d514e0e1a0b9195f5d2553fdc04cf78 to your computer and use it in GitHub Desktop.
using Microsoft.Azure.EventHubs;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs.ServiceBus;
using StackExchange.Redis;
using System;
using System.Threading.Tasks;
namespace OrderedEventHubs
{
public static class EventHubTrigger
{
private static ConnectionMultiplexer redis = ConnectionMultiplexer.Connect(Environment.GetEnvironmentVariable("Redis"));
private static IDatabase db = redis.GetDatabase();
[FunctionName("SingleMessageTrigger")]
public static async Task Single(
[EventHubTrigger("ordered", Connection = "EventHub")] EventData eventData,
TraceWriter log)
{
try
{
await db.ListRightPushAsync(
"events:" + eventData.Properties["partitionKey"],
(string)eventData.Properties["counter"]);
}
catch
{
// handle event exception
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment