We have a logic app which uses Azure APIM connector to call a API in azure API management instance that call one of the backend service. Sometime when our backend server is too busy it takes few seconds to return a response. But it process the request and create the records in out backend. In the logic app side it fails the request and send another request to API management endpoint because of the retry policy that we have for the call APIM action (Default). This creates duplicate records in our backend. In API management logs I can see the initial request has been failed "Client connection was unexpectedly closed" error. Is there any way to in increase the wait time of the APIM connector in the logic apps?
2
Answers
Alternative way to call APIM is by using HTTP action with Asynchronous pattern enabled as below:
Now the above action will wait until it will get 202 response from API call or HTTP call.
Or you can use HTTP Webhook which is used for Long running process and calling http urls:
There is likely a timeout configured between APIM and your backend system as well,
Inspect the policy from the service and verify the policy action in the XML. If you are using a forward-request action for example, the timeout is standard 2mins, which might not be sufficient.
Also verify the logic app settings, if you are using logic app standard, tweak the HTTP timeout accordingly such as
Runtime.Backend.HttpOperation.RequestTimeout
, you can find information about this Built-in HTTP operations