Increasing the connection Timeout time for Azure APIM connector in logic app

Banuka 5 Reputation points
2024-07-05T04:07:03.5866667+00:00

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?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,927 questions
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,968 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 23,411 Reputation points
    2024-07-05T10:37:44.2266667+00:00

    @Admin Banuka Thanks for reaching out. It seems like the issue is caused by the backend service taking too long to respond, which is causing the Azure APIM connector in the Logic App to time out and return a 504 error to the Logic App client. The APIM backend is taking all the time and APIM is just waiting for it, which is resulting in a "ClientConnectionFailure" error.

    There are two options to resolve this issue:

    1. Logic App timeout can be increased from the current to 120 second timeout max as per this doc https://learn.microsoft.com/en-us/azure/logic-apps/edit-app-settings-host-settings?tabs=azure-portal#managed-connector-operations. This may give more time for the backend service to respond and prevent the timeout error.
    2. You can filter down the query that you're sending to APIM, which should result in a smaller data set and quicker response time. This may help to reduce the backend time and prevent the timeout error.

    Let me know if you have any other questions or concerns.

    1 person found this answer helpful.