Thanks for reaching out to Q&A.
You can make use of the messageHandlerOptions.autoComplete property in the host.json file. This property is set to true by default. When set to false, you are responsible for calling MessageReceiver methods to complete, abandon, or deadletter the message. If an exception is thrown (and none of the MessageReceiver methods are called), then the lock remains. Once the lock expires, the message is re-queued with the DeliveryCount incremented and the lock is automatically renewed.
Azure Functions triggered by Service Bus events auto-complete messages by default. This means a successfully processed message is automatically completed. If an error happens when the message is processed, the message is abandoned and returned to Service Bus. Upon having been delivered a number of times to the function (specified by the maxRetryCount), the message is dead-lettered. Hence, the application has no direct control of the fate of incoming messages.
Usually there is a possibility to deactivate message auto-completion. In this case, the application must decide on its own what happens with incoming messages. There are usually 4 possibilities: complete, abandon, defer or dead-letter a message. This gives applications a lot more flexibility for error-handling.
I hope this helps!
Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.