将Azure功能与事件中心集成(Integrate Azure Functions with Event Hub)

系统教程 行业动态 更新时间:2024-06-14 16:53:07
将Azure功能与事件中心集成(Integrate Azure Functions with Event Hub)

我从EventHub触发器模板创建了一个Azure函数。 但我坚持两个问题:

a)如何指定非默认的消费者群组?

b)有没有办法获取整个EventData对象而不仅仅是消息字符串?

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?

最满意答案

更新 :现在也可以在门户中指定消费者组(下面提到的问题已得到修复)。

对于您的第一个问题,我们有一个跟踪问题的问题,我们很快就会发现( 此处有回购问题)。

对于你的第二个问题,我假设你是从我们的C#模板开始的,它使用了字符串,但是你可以将它改为EventData (其中参数“evt”的名称与你在绑定中选择的名称相匹配):

#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}"); }

有关可能的绑定的更多信息,请参见此处的EventHub wiki页面。 您也可以通过许多其他方式进行绑定,例如您自己的POCO类,一系列事件等。

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.

更多推荐

本文发布于:2023-04-05 21:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/f1cd6133b5dffc2a9de6a8f799ac2bda.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   功能   中心   Azure   Hub

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!