I wonder if there is a way to force Azure Function to re-process messages that have already been processed. I deployed a new function version to DEV environment, but it looks like DEV EventHub is not active. I'd like to re-process old messages that still sit in the EventHub.
I tried to stop an app, edit partitions metadata in azure-webjobs-eventhub
blob to set sequencenumber
to a past number and start the app. No luck, function doesn't run.
Example of what I did, I edited metadata of this blob:
company1.servicebus.windows.net/eventhub1/listener1/checkpoint/0
and subtracted 100 from sequencenumber
I guess it is not working because I have to change offset
as well.
My other idea is to delete blobs altogether, I think functions should start pulling messages from the beginning. That's a bit too much for testing.
I can try to retrieve a message by sequence number and lookup the offset to use in the message. That's a bit more work. I wonder if there is an easier way.
We generally recommend that you delete the checkpoint blob and rely on the initialOffsetOptions/enqueuedTimeUtc
in host.json to roll back processing. Setting the wrong metadata for a checkpoint can potentially introduce bad data that causes the associated partition to continually fail.
That said, your approach would work if you deleted the offset
metadata item. When a checkpoint is read, offset
always takes precedence for positioning the reader. Sequence number is tracked mostly for legacy compatibility, as some applications use it to compute how far behind readers are.
However, there is logic that falls back to using the sequence number to position the reader if an offset was not present.
If you decide to move forward with this, I'd strongly advise testing in your development environment first. This isn't an officially supported scenario (our checkpoints will always have an offset) and thus isn't something we have robust test coverage on internally.