Functions事件中心触发器绑定

Functions事件中心触发器绑定

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

问题描述

关于在物联网场景中将Azure功能与EventHub结合使用仅存在几个问题.

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

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

谢谢

推荐答案

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 IEventProcessorhere.

对您的问题:

  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事件中心触发器绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 16:01