This blog will give you a recap of the feature content that was discussed as a part of Episode 22 of Middleware Friday. In this episode, Kent Weare discussed a small, yet very interesting feature in Azure Logic Apps – the Retry Policy.
Logic App Retry Policy
To understand the Retry Policy better, let’s assume we have an endpoint that is consumed by Logic Apps. If the endpoint has some intermittent issues, and the initial request fails to execute, the number of retries will be attempted based on the “retry count” default settings. By default, the retry action will execute 4 additional times over 20-second intervals. The retry policy applies to intermittent failure HTTP codes like 408, 429, 5xx series. You can define the retry policy as follows:
"retryPolicy" : {
"type": "<type-of-retry-policy>",
"interval": <retry-interval>,
"count": <number-of-retry-attempts>
}
The maximum number of retry attempts that can be made is 4. If you try tweaking the retry count in the JSON, during the Logic App execution you will notice an exception as “The provided retry count of ‘value’ is not valid. The retry count must be a positive number no greater than ‘4’“. Similarly, the maximum delay for a retry can be set to 1 hour while the minimum delay is 5 seconds. Azure Logic Apps uses ISO 8601 standards for the above mentioned time durations and you need to define the interval in one of the following formats –
PnYnMnDTnHnMnS |
PnW |
P<date>T<time> |
Demo – With Default Retry Mechanism
Kent demonstrated the Azure Logic App Retry Policy with the help of the following Logic App example –
Prerequisite: Create a Logic App before proceeding with the steps shown below
- First, let’s start with a Blank Logic App. In the Logic App designer, we will get started with creating a simple HTTP request trigger.
- Next, we will create an HTTP POST method and give a fake URL (URI) to allow the retry mechanism to kick in
- Finally, an HTTP response action with the status code of 200 to complete the Logic App
After about 70 seconds, the fourth retry is performed.
Finally, after 80 seconds, the Logic App execution will fail and the corresponding error will be displayed in the Logic App Designer.
You can alter the retry mechanism by entering the code view and modifying the code with the values as shown previously in the blog post.
Therefore, the demo clearly shows how the retry policy works out of the box in Logic Apps and how you can customize the retry policy within its limits. You can watch the video ofMiddleware Friday sessions here.