Best practice for resiliency and redundancy

jabing 1 Reputation point
2020-08-19T00:18:58.2+00:00

Hello,

What are the best practices for resiliency and redundancy for Azure Functions?

We're developing an application and on occasions our app gets "stuck" and needs to be restarted. We'd like to automate this process, or identify if there is a way for a failing function to automatically trigger a failover function app to prevent down-time.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,073 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JayaC-MSFT 5,531 Reputation points
    2020-08-19T16:04:39.937+00:00

    @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.

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.