is there a sleep policy or any alternative in azure apim so that i can delay for 5 seconds to particular response?enter image description here In the attached image i need to give 5 seconds of delay or sleep condition to the highlighted condition.
Azure APIM sleep or delay policy
2.3k Views Asked by Deepak Jain At
3
There are 3 best solutions below
0

You can use the retry policy to emulate a delay:
https://learn.microsoft.com/en-us/azure/api-management/api-management-advanced-policies#Retry
<retry condition="@(true)" count="1" interval="5" />
0

There's no in built policy which supports delay. Still as a work around following policy can be included.
Following policy sets a variable after 500 milliseconds.
<set-variable name="delayExpression" value="@{
var curr = System.DateTime.UtcNow.AddMilliseconds(500);
while(System.DateTime.UtcNow < curr){
continue;
}
return System.DateTime.UtcNow;
}"/>
That is not possible with APIM alone. You could make a call to another endpoint using send-request, that would delay APIM's response, but you have to have such endpoint first.