write to file sequentially using azure queue

javier 916 Reputation points
2022-07-20T22:55:14.807+00:00

new to queues here.

I have many tasks in a queue where each of them consist in appending data to a file through a function app. I want to perform those tasks sequentially.

My understanding from the docs is that I need to set batchSize to 1 in host.json in order to get the messages processed sequentially:

{  
  "version": "2.0",  
  "extensions": {  
    "queues": {  
      "maxDequeueCount" : 3,  
      "batchSize": 1,  
      "newBatchThreshold": 1000,  
      "messageEncoding" :"none"  
    }  
      
  },  
  "extensionBundle": {  
    "id": "Microsoft.Azure.Functions.ExtensionBundle",  
    "version": "[2.*, 3.0.0)"  
  }  
}  

Is this the correct way of achieving sequential processing of the tasks?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,210 questions
Azure Queue Storage
Azure Queue Storage
An Azure service that provides messaging queues in the cloud.
96 questions
0 comments No comments
{count} votes

Accepted answer
  1. Bruno Lucas 4,411 Reputation points MVP
    2022-07-21T08:26:04.04+00:00

    Hi @javier
    There is also the problem o parallelism and queue storage does not support fifo (first in first out)
    This article has a very good explanation on how far you can go with storage queues:
    https://laurakokkarinen.com/forcing-an-azure-function-to-process-queue-storage-messages-one-at-a-time/

    223091-image.png

    223018-image.png

    if you need to guarantee sequential processing, you will be better with azure service bus using the convoy pattern:
    https://learn.microsoft.com/en-us/azure/architecture/patterns/sequential-convoy

    Please don't forget to click on "Accept Answer" or the vote button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. javier 916 Reputation points
    2022-07-21T15:01:21.307+00:00

    @Bruno Lucas this is great. I am not looking for FIFO processing, just one-at-a-time processing your answer should work perfectly. thanks

    0 comments No comments