Reputation: 1769
Is it possible to do trigger an Azure Function only when all items are processed in the Queue?
I have a Queue containing multiple Validations that needs to be done. Only after all the validations are validated it should trigger the next Azure Function that will create a report out of these validations
What I've tried
After an item is process store the result (validations.Processed = True
) and then do a check
bool allProcessed = !validations
.Where(v => v.LabFormulierId == validation.LabFormulierId)
.Where(!x.Processed)
.ToList()
.Any();
Add it to a temp Table, and remove it from the table when the items are finished processing
bool allProcessed = !validationsToDo
.Where(v => v.LabFormulierId == validation.LabFormulierId)
.ToList()
.Any();
And then later on check if all are processed with this var, and only then fire off the next Azure Function
...
if (allProcessed)
{
await createReportQueueCollector.AddAsync(formulier);
log.Info($"Add Formulier {formulier.Guid} to create-report queue");
}
Both did not work for me... Is there a clean way to do this?
Upvotes: 0
Views: 232
Reputation: 35154
In your code it's not clear what validations
are and whether you store them externally.
Have a look at Durable Functions, they provide higher level API to correlate multiple actions. Queues are used behind the scenes but in a way hidden from developer.
Upvotes: 1