Search code examples
azurec#-4.0azure-blob-storagedynamics-crm-online

Concurrency problem with Azure Blob Storage function


Azure function is processing multiple files in blob storage at same time. This is causing duplicate data creation in dynamics CRM because azure function is processing multiple file in parallel execution. Can someone help me , how i can restrict azure function to process one file at a time?


Solution

  • According to the section Trigger - concurrency and memory usage of the offical document Azure Blob storage bindings for Azure Functions, as the figure below.

    The blob trigger uses a queue internally, so the maximum number of concurrent function invocations is controlled by the queues configuration in host.json. The default settings limit concurrency to 24 invocations. This limit applies separately to each function that uses a blob trigger.

    enter image description here

    So you can follow the content of the host.json template file as below to set the queues.batchSize value to 1 to restrict Azure Function with Blob Trigger to process one file per time.

    enter image description here

    As references, there are two similar SO threads which you can also refer to.

    1. Azure Functions - Limiting parallel execution
    2. Throttling Azure Storage Queue processing in Azure Function App