2

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.

3 Answers3

8

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" />
Joe Eng
  • 1,072
  • 2
  • 15
  • 30
0

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.

Vitaliy Kurokhtin
  • 7,205
  • 1
  • 19
  • 18
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;
            }"/>