Jump to content

Long execution functions with Service Bus Trigger


Recommended Posts

Guest theringe
Posted

Function App under at least a Premium plan could have unlimited execution time. However, it might caused a duplicated invocation issue with a ServiceBus trigger because the "PeekLock" duration is up to 5 minutes (including renew).

 

 

 

It is a tutorial to reproduce such the scenario.

 

 

 

STEP 1: In Azure portal, create a new Premium python Function App and a Service Bus + Queue

 

 

 

STEP 2: Download the sample code and apply some changes.

 

https://cchlab.blob.core.windows.net/cchlab/cchlabsbf.zip

 

In "host.json", please specify the Function App timeout and the ServiceBus PeekLock timeout as below.

 

mediumvv2px400.png.142263f8607d04f5fbddbc549327a1fe.png

 

In "ServiceBusQueueTrigger1/function.json", please setup some configuration:

 

SBQ_STRING=<your service bus queue name>

 

mediumvv2px400.png.1dbc5b37d1eed13a155d58adfb09ca23.png

 

Then, deploy the project to Function App.

 

 

 

STEP 3: Making an experiment with a short execution time.

 

Visit: https://<YourAppName>.azurewebsites.net/api/httptrigger1?t=<DurationInSecond>

 

Please specify the "DurationInSecond" to 30 this time, and you may see the result like this:

 

mediumvv2px400.png.4fa9334717e29d686d405fb055a808b4.png

 

We apply this operation to send a message to the ServiceBus queue and told the ServiceBus trigger to pause 30 seconds before execution.

 

Now, please go to the monitor page:

 

mediumvv2px400.png.73dcddaed68f89a317369980d33d6c05.png

 

You can see it is just a normal short invocation.

 

 

 

STEP 4: Making an experiment with a long execution time.

 

Visit: https://<YourAppName>.azurewebsites.net/api/httptrigger1?t=<DurationInSecond>

 

Please specify the "DurationInSecond" to 330 this time, and you may see the result like this:

 

mediumvv2px400.png.f59e9f545465e06ffbb6f756b223cac7.png

 

Now, please go to the monitor page:

 

mediumvv2px400.png.c193fe32c6f40a93e9a15a2a89e535c3.pngmediumvv2px400.png.2e506e9054aff48a064fa015b601fd62.pngmediumvv2px400.png.1dcf94d89a9aee3aed1b293f254d985a.png

 

As you can see, there are duplicate invocations with the same message id, which might caused some potential business issues if we ignore them.

 

 

 

Conclusion:

 

Since we cannot adjust "maxAutoRenewDuration" to more than 5 minutes, we could only reduce the execution time from this ServiceBus trigger.

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...