Search code examples
c#.netazureazure-functionsauto-renewing

Azure Function Setting autoRenewTimeout in host json file not working


I am using Azure Function to read Message from the Queue which takes a long time and for that, I have used autoRenewTimeout in the host.json file but still, the message reappears in the queue while it is being processed.

My Requirement is to process the message for long hours below is the json configuration file.

"version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingExcludedTypes": "Request",
      "samplingSettings": {
        "isEnabled": true
      }
    }
  },
  "serviceBus": {
    // the maximum duration within which the message lock will be renewed automatically.
    "autoRenewTimeout": "05:00:00"
  },
  "functionTimeout": "05:02:00"
}

Solution

  • I think you have configured host.json using V1 Function reference. For V2 and later, the config has changed. Refer this for Service Bus section and refer this for over host.json for V2+. Below is just a sample, adjust as per your need.

    {
        "version": "2.0",
        "extensions": {
            "serviceBus": {
                "prefetchCount": 100,
                "messageHandlerOptions": {
                    "autoComplete": true,
                    "maxConcurrentCalls": 32,
                    "maxAutoRenewDuration": "00:05:00"
                },
                "sessionHandlerOptions": {
                    "autoComplete": false,
                    "messageWaitTimeout": "00:00:30",
                    "maxAutoRenewDuration": "00:55:00",
                    "maxConcurrentSessions": 16
                }
            }
        }
    }