我可以更改Azure Function Event Hub触发器启动检查点吗? [英] Can I change the Azure Function Event Hub trigger starting checkpoint?

查看:77
本文介绍了我可以更改Azure Function Event Hub触发器启动检查点吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我站起来一个新的Azure Function来监听我们的事件中心时,有了一个新的消费者组,它会获得所有发送到事件中心的消息,即使是几个月前也是如此.我认为将集线器上的邮件保留时间设置为一天会限制该时间,但显然没有限制.无论如何,我真的只希望新的Azure Function从初始部署或测试点开始接收事件,但是我不知道如何指定该初始开始检查点,因为AF将这些东西神奇地存储在存储中.

如果我手动执行集线器逻辑,则可以指定此检查点并从任意时间(例如当前时间)开始.有没有一种方法可以使用Azure函数复制它?

解决方案

好消息是,您可以更改检查点.那里没有太多魔术:检查点存储在Blob存储-> azure-webjobs-eventhubs容器中的Blob中,其名称类似于yournamespace.servicebus.windows.net/yourhub/$Default/X,其中$Default是使用者组名称,而X是分区号.

以下是此类Blob的示例:

 {"PartitionId":"0","Owner":null,"Token":null,"Epoch":567,"Offset":"14992",
 "SequenceNumber":156}
 

坏消息是,您需要在要开始的那一刻就知道偏移量,而您可能不知道.然后,您需要继续手动或使用自定义代码来修改Blob.并且应该在Function App启动之前执行此操作.

由您决定是否可以/想要这样做. AFAIK,没有简单而正式的方法可以做到这一点.

When I stand up a new Azure Function listening to our event hub, with a new consumer group, it gets all the messages that have ever been sent to the event hub, even from months ago somehow. I thought setting the message retention on the hub to one day would limit that, but apparently not. Anyway, I really only want the new Azure Function to receive events from the initial deployment or testing point onward, however I don't know how I can specify that initial starting checkpoint, since that stuff is magically done in storage by AF.

If I'm doing the hub logic manually I can specify this checkpoint and start from an arbitrary time, such as the current time. Is there a way to replicate this with an Azure Function?

解决方案

The good news is Yes, you can change the checkpoint. There is not much magic there: the checkpoints are stored in Blob Storage -> azure-webjobs-eventhubs container in blobs with names like yournamespace.servicebus.windows.net/yourhub/$Default/X, where $Default is consumer group name and X is partition number.

Here is an example of such blob:

{"PartitionId":"0","Owner":null,"Token":null,"Epoch":567,"Offset":"14992",
 "SequenceNumber":156}

The bad news is that you need to know your offset for the moment you want to start at, and you probably don't know it. And then, you need to go ahead and modify the blobs either manually or with custom code. And you should do that before the Function App starts.

It's up to you to decide whether you can/want to do that. AFAIK, there's no easy and official way to accomplish this.

这篇关于我可以更改Azure Function Event Hub触发器启动检查点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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