Logic app SFTP - SSH: each trigger opens a new connection to the sftp server

Simone Ferrari 0 Reputation points
2025-03-25T17:07:46.09+00:00

We created a new logic app (consumption) with these requirements:

  • it must open a connection to an sftp server
  • it must retrieve all the files in a folder
  • each file must be moved to a sharepoint folder
  • one moved, file must be delete by sftp folder

We added SFTP - SSH triggers/actions:

  • list files in a folder
  • get file content (infer content type = Yes)
  • delete file

For each action has concurrency control = Yes and Degree of parallelism = 1.

Each SFTP - SSH trigger/action open always a new connection to the sftp server, without using cached connection.

SFTP server has a ClientAliveInterval = 30 minutes and maximum 5 active connection at the same time. So at the 3rd file processed we received the issue "bad request" cause the sftp server does not accept any other connection over than 5 at the same point.

Also there is no way to set a property to close the sftp connection by the logic app.

Anyone can help me with this case?

Thank you

Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
3,550 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Loknathsatyasaivarma Mahali 2,740 Reputation points Microsoft External Staff Moderator
    2025-03-27T16:27:07.1966667+00:00

    Hello Simone Ferrari,

    The Logic Apps Consumption SFTP-SSH connector's inability to reuse or explicitly close connections, coupled with your SFTP server's connection limits, necessitates a shift to an Azure Function.

    Solution: Implement an Azure Function.

    • The function establishes one persistent SFTP connection and it handles all SFTP actions (list, get, delete) and SharePoint transfer within that connection.
    • Also, the function explicitly closes the SFTP connection, preventing resource exhaustion.

    This approach provides the necessary connection control, overcoming the SFTP-SSH connector's limitations. While it requires refactoring, it's the reliable way to ensure your workflow's success.

    0 comments No comments

  2. Sonny Gillissen 3,751 Reputation points Volunteer Moderator
    2025-03-31T20:48:57.04+00:00

    Hi Simone Ferrari

    Thanks for reaching out on Microsoft Q&A!

    As I understand you’re experiencing connection issues within your logic app while connecting to an SFTP over SSH due to persistancy.

    What you could do to avoid this case is to “debatch” your files to another logic apps meaning: the logic app with the trigger executes the loop, but within the loop the file data is passed through to another logic app handling the file.

    This way each subsequent logic app has it’s own one-on-one connection to the SFTP, only for that single file it should handle. Every next file is handled within another run thus another connection living on its own.

    Please click ‘Accept answer’ if you think my answer is helpful. Feel free to drop additional queries in the comments below!

    Kind regards,

    Sonny


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.