Concurrency in Azure Function fails. BlobTrigger .NET8 C#

Gonzalo Gomez 15 Puntos de reputación
2024-01-12T21:09:33.57+00:00

I have an Azure Function App with a BlobTrigger function. It triggers when a new blob is stored in the blob storage and uploads it to a DB. It is configured to have dynamic concurrency. When a blob arrives it triggers and uploads it to the DB. But when two or more blobs arrive at the same time, it triggers for all of them, but it only uploads one to the DB. I am using

Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs Version="6.2.0"

This is my host.json file:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      },
      "enableLiveMetricsFilters": true
    },
    "logLevel": {
      "Host.Concurrency": "Trace"
    }
  },
  "concurrency": {
    "dynamicConcurrencyEnabled": true,
    "snapshotPersistenceEnabled": true
  }
}
Azure
Azure
Plataforma e infraestructura de informática en la nube para crear, implementar y administrar aplicaciones y servicios a través de una red mundial de centros de datos administrados por Microsoft.
590 preguntas
0 comentarios No hay comentarios
{count} votos

1 respuesta

Ordenar por: Muy útil
  1. Gao Chen 10,665 Puntos de reputación Personal externo de Microsoft Moderador
    2025-01-22T17:52:55.3833333+00:00

    Hello Gonzalo Gomez,

    Welcome to Microsoft Q&A!

    We are very sorry for the delay in giving you a response to your topic in this forum. If you still have the same inquiry, it sounds like you're encountering an issue with concurrency handling in your Azure Function App. Here are a few steps you can take to troubleshoot and potentially resolve this issue:

    Check Dynamic Concurrency Configuration: Ensure that dynamic concurrency is correctly configured in your host.json file. It should look something like this:

       {
         "version": "2.0",
         "extensions": {
           "blobs": {
             "maxDegreeOfParallelism": -1
           }
         },
         "concurrency": {
           "dynamicConcurrencyEnabled": true
         }
       }
    

    Update to the Latest Version: Consider updating to the latest version of the Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs package. The latest version as of now is 6.6.0. There might be bug fixes or improvements that could resolve your issue.

    Logging and Monitoring: Enable detailed logging to monitor the behavior of your function when multiple blobs are uploaded. This can help identify if the function is being throttled or if there are any errors during execution.

    Concurrency Limits: Verify if there are any limits set on the maximum concurrency for your function. You can set these limits in the host.json file under the concurrency section.

    Database Transaction Handling: Ensure that your database transactions are correctly handled to avoid conflicts when multiple instances of the function try to upload data simultaneously. Implementing proper locking mechanisms or using unique identifiers for each blob can help.

    Testing Locally: You can test the dynamic concurrency feature locally using the Azure Storage Emulator or Azurite. This can help you simulate the behavior and make necessary adjustments before deploying to production.

    If these steps don't resolve the issue, you might want to check the official documentation or reach out to the Azure support team for more specific guidance.

    I hope the information provided was useful! Additionally, please kindly note that if we do not receive a response to this thread within 4 business days, we will consider it closed. In case you have the same question, and the information provided was not useful, feel free to create another thread and we will be more than happy to help you.

    Regards,

    Gao


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comentarios No hay comentarios

Su respuesta

Las respuestas se pueden marcar como respuestas aceptadas por el autor de la pregunta, lo que ayuda a los usuarios a conocer la respuesta que resolvió el problema del autor.