0
votes

I am new to Azure API management. We are calling an external web api from Azure API management. If the web api is not able to communicate with the Azure API management, we are trying for a couple of retry before give up.

We have added a retry policy in the outbound node (policy) to check the response status of the backend node (policy). If the response status is other than 200 then we are trying to call the web api again after 10 seconds. We want to give 2 try before give up.

The problem is outbound node (policy) always execute send-request node (policy), even we just write

<retry condition="@(false)" count="2" interval="10" first-fast- 
retry="false">
<send-request.....>
......
......
</send-request>
</retry>

How to write a condition in the retry policy so that it will get checked before executing the child nodes.

<outbound>
<base />
<retry condition="@(context.Response.StatusCode != 200)" count="2" interval="10" first-fast-retry="false">
<send-request mode="new" response-variable-name="responseVar" ignore-error="false">
<set-url>... </set-url>
<set-method>POST</set-method>
<set-body>...</set-body>
<set-header>...</set-header>
</retry>
</outbound>
1
Where is this policy configured ? API / Product / Operation level ? Also, did you check if external API is working as expected (returning 200) ?Manoj Choudhari
The policy is configured in API at operation level. Yes, external API is working as expected and returning 200.HowsTheJosh

1 Answers

0
votes

Retry always executes its inner policies and only checks condition after first and subsequent executions. The idea is to check some result of inner policies to determine if they need to be executed again. To check condition upfront you'll have to wrap it into choose policy.