@jabing You can check https://learn.microsoft.com/en-us/azure/azure-functions/functions-geo-disaster-recovery to avoid downtime. This will make sure of the high availability of the application.
If the invocation is stuck in case of long-running functions can cause unexpected timeout issues. To learn more about the timeouts for a given hosting plan, see https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale#timeout
You may also try retry mechanism based on the type of trigger : https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-error-pages#retry-support
If you are using http trigger, you can implement process data asynchronously. This prevents HTTP response timeouts on long-running functions and frees up the referring service/thread to continue processing.
https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#async-http
Now if the execution is stuck at the code level, it is advised to fine tune the code.
You can also leverage Azure Monitor feature to check (in Application Insights etc.) if there is any timeout exception for that function (http 504 – gateway Timeout). In that case, invoke an alert when there is any gateway timeout error, which will start a logic app. In the logic app, we can use the management API endpoint to restart the function app. [ Management API ref : https://learn.microsoft.com/en-us/rest/api/appservice/webapps/restart]
Please let me know if this helps answer your question.