About Azure Functions maxDequeueCount in host.json

Jona 495 Reputation points
2024-06-23T06:44:44.7533333+00:00

Hi,

I'm using Azure Functions (Python) and configuring to executed the function just once so that it terminates and send the message to poison queue.

I'm setting maxDequeueCount to one, but it won't work. This is my host.json file

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 6.0.0)"
  },
  "extensions": {
    "eventHubs": {
        "maxEventBatchSize" : 500,
        "minEventBatchSize" : 200,
        "maxWaitTime" : "00:0:05",
        "clientRetryOptions":{
            "mode" : "exponential",
            "tryTimeout" : "00:01:00",
            "delay" : "00:00:00.80",
            "maximumDelay" : "00:01:00",
            "maximumRetries" : 1
        }
    },
    "queues": {
      "maxPollingInterval": "00:00:02",
      "visibilityTimeout" : "00:00:30",
      "batchSize": 16,
      "maxDequeueCount": 1,
      "newBatchThreshold": 8,
      "messageEncoding": "base64"
    }
  }
}

The message from the local console debugging is telling me that it tries 5 times before sending the message to poison queue.

queue

Regards

Jona

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

2 answers

Sort by: Most helpful
  1. Pinaki Ghatak 5,310 Reputation points Microsoft Employee
    2024-06-28T20:16:46.26+00:00

    Hi @Jona

    Based on the provided host.json file, the maxDequeueCount is set to 1, which means that the function should be retried only once before being sent to the poison queue.

    However, it seems that the function is being retried five times before being sent to the poison queue. One possible reason for this behavior is that the function is failing with a transient error, which is causing the function to be retried multiple times. To confirm this, you can check the logs for the function execution and see if there are any errors being logged.

    If the function is failing with a transient error, you can try increasing the clientRetryOptions maximumRetries property to a higher value to allow for more retries before sending the message to the poison queue. If the function is not failing with a transient error, then there might be an issue with the host.json file. In this case, you can try removing the host.json file and letting Azure Functions use the default settings to see if the issue persists


    I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.

    0 comments No comments

  2. Jona 495 Reputation points
    2024-06-28T22:02:02.62+00:00

    Hi @Pinaki Ghatak

    If the function is failing with a transient error, you can try increasing the clientRetryOptions maximumRetries property to a higher value to allow for more retries before sending the message to the poison queue

    ¿Are the settings you mention just for Event Hub trigger? I don't see how thet applied to the Queue.

    If I'm wrong about something, pls let me know.

    Regards

    Jona


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.