简体   繁体   中英

Integrate Azure Functions with Event Hub

I've created a Azure function from EventHub-trigger template. But I've stuck with two issues:

a) How to specify the consumer group other than default?

b) Is there any way to get whole EventData object rather than just the message string?

Update : Consumer Group can now be specified in the portal as well (issue mentioned below has been fixed).

For your first question, we have an issue tracking that and we'll get to it soon (repo issue here ).

For your second question, I'm assuming you're starting from our C# template, which uses string, but you can change that to EventData (where the name of the parameter "evt" matches the name you chose in your binding):

#r "Microsoft.ServiceBus"

using System;
using Microsoft.ServiceBus.Messaging;

public static void Run(EventData evt, TraceWriter log)
{
    var id = evt.Properties["id"];
    log.Info($"C# Event Hub trigger function processed event: {id}");
}

See the EventHub wiki page here for more information on possible bindings. You can bind in many other ways as well, for example your own POCO class, an array of events, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM