Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Auto Renew Message Timeout using ServiceBusTrigger in Azure Function with C#?

When using the ServiceBusTrigger with Azure Functions to trigger the function to execute on new messages in a Service Bus Queue, their doesn't seem to be a way to auto renew the message timeout. Sure, you can always call the BrokeredMessage.RenewLock method, but with Functions there appears to be no way to configure it to auto renew the message lock.

Is there a way anyone has found to configure an Azure Function to Auto Renew the BrokeredMessage lock while a Service Bus Queue message is being processed?

Yes, I know you can increase the default timeout on the Service Bus Queue, but the maximum configurable default timeout is 5 minutes; which can still be too short .

Thanks!

Here's an example of using the ServiceBusTrigger attribute in C# when building an Azure Function like mentioned using Visual Studio. Notice, the ServiceBusTrigger usage does not allow a Timeout Duration to be set, or an Auto Renew to be configured either.

[FunctionName("MyFunction1")]
public static async Task Run(
    [ServiceBusTrigger("queuename", AccessRights.Listen, Connection = "AzureServiceBus")] BrokeredMessage sbCommand,
    ILogger log)
{
    // process message here
}
like image 601
Chris Pietschmann Avatar asked Jan 15 '19 13:01

Chris Pietschmann


People also ask

How do I increase the timeout on my azure function?

The functionTimeout in the host. json file can be configured using a timespan string format ranging from a minimum of 1 second ( 00:00:01 ), up to a maximum of 10 minutes ( 00:10:00 ) for Consumption Plan hosting and Unlimited ( -1 ) for Premium and Dedicated Plans .

Does Azure function have timeout?

Function app timeout duration Regardless of the function app timeout setting, 230 seconds is the maximum amount of time that an HTTP triggered function can take to respond to a request. This is because of the default idle timeout of Azure Load Balancer.

What is default timeout for Azure functions in consumption plan?

By default, Azure functions timeout after 10 minutes (or 30 minutes if running in an App Service Plan, or a Premium plan).

What is service bus trigger in Azure function?

Azure Functions integrates with Azure Service Bus via triggers and bindings. Integrating with Service Bus allows you to build functions that react to and send queue or topic messages.


1 Answers

The function renews the message lock by itself. You don't need to renew the lock manually, it is handled by the run time of the function. Please refer this article.

like image 87
Arunprabhu Avatar answered Oct 02 '22 12:10

Arunprabhu