Azure Functions 事件中心触发器绑定 [英] Azure Functions Event Hub trigger bindings

查看:34
本文介绍了Azure Functions 事件中心触发器绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是有几个关于在 IoT 场景中使用 Azure Functions 和 EventHub 的问题.

Just have a couple of questions regarding the usage of Azure Functions with an EventHub in an IoT scenario.

  • EventHub 有分区.通常来自特定设备的消息会进入同一分区.Azure Function 的实例如何跨 EventHub 分区分布?是基于性能吗?如果 Azure 函数的一个实例设法处理来自所有分区的事件,那么这就足够了,否则最终每个 EventHub 分区可能只有一个 Azure 函数实例?
  • 读取偏移量如何?这个绑定是否以某种方式记录了它停止读取事件流的位置?我认为这些函数是无状态的,这里我们有一些状态.

谢谢

推荐答案

Function Apps 基于 WebJobs SDK,它使用 EventHostProcessor 来使用来自事件中心的事件.所以你可以查询EventHostProcessor的信息,它会适用于你的Function App.

Function Apps are based on WebJobs SDK, which use EventHostProcessor to consume events from Event Hubs. So you can lookup information about EventHostProcessor and it will be applicable to your Function App.

特别是可以找到IEventProcessor的实现这里.

Particularly, you can find the implementation of IEventProcessor here.

回答您的问题:

  1. 不确定一个实例"是什么意思.每个分区将创建一个侦听器,但如果负载较低,它们可以同时托管在单个 App Plan 实例中.在高层次上,您不应该太在意:在消费计划中,您按执行时间付费,无论有多少服务器/进程/线程正在运行.当然,您应该关心自动缩放对于高负载是否足够好,但无论如何都需要进行测试.

  1. Not sure what you mean by "one instance". One listener will be created per partition, but they can be both hosted inside a single App Plan Instance if the load is low. On the high level, you should not care much: in Consumption Plan you pay per execution time, no matter how many servers/processes/threads are running. Of course, you should care whether the auto-scaling works good enough for high load, but that needs to be tested anyway.

从某种意义上说,函数是无状态的,您无法在两次函数执行之间在内存中保存任何内容.您完全可以将状态保存在外部存储中.Function App 将使用 PartitionContext.CheckpointAsync() 来检查当前偏移量.Azure 存储在内部使用;您可以再次阅读有关它在事件中心和 EventHostProcessor 文档中如何工作的更多信息,例如此处.

Functions are stateless in a sense that you can't save anything in-memory between two function executions. You are totally fine to save state in external storage. Function App will use PartitionContext.CheckpointAsync() for checkpointing of the current offset. Azure Storage is used internally; again you can read more about how it works in Event Hubs and EventHostProcessor docs, e.g. here.

这篇关于Azure Functions 事件中心触发器绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆