An error has occurred in my function app and it was shutdown. "Singleton lock renewal failed for blob
with error code 409: LeaseIdMismatchWithLeaseOperation. The last successful renewal completed at 2023-12-15T20:43:56.694Z (130861 milliseconds ago) with a duration of 6 milliseconds. The lease period was 60000 milliseconds."
And then it logged this error and was shutdown
"An unhandled exception has occurred. Host is shutting down."
This occurred in executing a timer trigger function. How can we prevent the host from shutting down when this or any other error happens? Is there a way to catch the exceptions that occur in host? I am using functions version 2.x.
I am just looking to prevent the app from shutdown/crashing.
In order to resolve 409 errors with the Function app, Make sure you use different storage accounts for different Function Apps. When the same storage account is shared between 2 or more functions they all write to the same storage account blob and leases. In order to avoid this error:-
Refer this Github comment by ThomasArdal
Also, Try implementing these setting to make the singleton behaviour successful in your Function app:-
host.json reference for Azure Functions 2.x | Microsoft Learn