问题描述
当我建立一个新的 Azure 函数来监听我们的事件中心,并使用一个新的消费者组,它会获取所有发送到事件中心的消息,甚至是几个月前的消息.我认为将集线器上的消息保留时间设置为一天会限制这一点,但显然不是.无论如何,我真的只希望新的 Azure Function 从初始部署或测试点开始接收事件,但是我不知道如何指定初始启动检查点,因为这些东西是由 AF 在存储中神奇地完成的.
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.
如果我手动执行集线器逻辑,我可以指定此检查点并从任意时间开始,例如当前时间.有没有办法用 Azure 函数复制它?
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?
推荐答案
好消息是,您可以更改检查点.那里没有什么神奇之处:检查点存储在 Blob Storage -> azure-webjobs-eventhubs
容器中,名称类似于 yournamespace.servicebus.windows.net/yourhub/$Default/X
,其中$Default
是消费者组名,X
是分区号.
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.
以下是此类 blob 的示例:
Here is an example of such blob:
{"PartitionId":"0","Owner":null,"Token":null,"Epoch":567,"Offset":"14992",
"SequenceNumber":156}
坏消息是你需要知道你想要开始的那一刻的偏移量,而你可能不知道它.然后,您需要继续手动或使用自定义代码修改 blob.您应该在 Function App 启动之前执行此操作.
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.
由您决定是否可以/想要这样做.AFAIK,没有简单而正式的方法可以做到这一点.
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 函数事件中心触发器启动检查点吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!