question

CRASH4-6874 avatar image
0 Votes"
CRASH4-6874 asked AnuragSingh-MSFT edited

Logic App SSH SFTP Connector- Bad Gateway (500)

Hi,
I am using SSH SFTP connector in Logic App to connect to a SFTP Server on port 22 using User ID/Password (no ssh keys). The connector is successfully connecting to the path and listing the available files using the 'List Files in Folder' action. However when trying to read the contents of the files using 'Get File Content' or 'Get File Content using Path' actions, receiving a Bad Gateway exception as follows:

{
"error": {
"code": 500,
"source": "",
"clientRequestId": "352750b6-1d9c-4fe1-82e6-0e2ee3f2e916",
"message": "BadGateway",
"innerError": {
"status": 500,
"message": "Specified argument was out of the range of valid values.\r\nParameter name: length\r\nclientRequestId: 352750b6-1d9c-4fe1-82e6-0e2ee3f2e916",
"error": {
"message": "Specified argument was out of the range of valid values.\r\nParameter name: length"
},
"source": "sftpwithssh-ncus.azconn-ncus.p.azurewebsites.net"
}
}
}

There are no IP whitelisting required at the SFTP server and able to connect using WinSCP from multiple devices. Not sure if this is due to any limitations with the Connector and please advise any possible solutions
Note: I am able to connect and retrieve the above files using Azure Function using Renci.SshNet.dll library, but facing issues via Logic App SSH SFTP connector

azure-logic-apps
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

AnuragSingh-MSFT avatar image
0 Votes"
AnuragSingh-MSFT answered CRASH4-6874 commented

Hi @CRASH4-6874,

Welcome to Microsoft Q&A! Thanks for posting the question.

I tested a scenario using the SFTP - SSH connector in Logic Apps and it worked as expected and I was able to get the content of file back. I connecting to SFTP enabled Azure Blob Storage from Logic Apps using only the userid/password (and not the ssh keys)

The limits for this connector are mentioned here, however I don't think that any of these might be related. The error message mentions:

 "Specified argument was out of the range of valid values.
 Parameter name: length
 clientRequestId: 352750b6-1d9c-4fe1-82e6-0e2ee3f2e916"

Based on my observation, there are no length related parameters as supplied in the activities/connector in Logic Apps. Can you please check if:

1. Is the "File Path/File Name" huge? Can you please test with a smaller file name?

2. Please check if the configuration of activities for "SFTP - SSH" look like below:

182078-image.png

3. Please check and ensure that there are no special/no-printable characters in the "File" or "File Path" fields.

4. Since the error is 500, this is coming from the server side. Please check if there is a way to get more details of this error - especially, why does it not like the get content request.

Please let me know if you have any questions.


Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


image.png (22.9 KiB)
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@CRASH4-6874, I wanted to check if you had a chance to review my answer above. Please let me know if you have any queries or concerns.

Please 'Accept as answer' if it helped so that it can help others in the community looking for help on similar topics.

0 Votes 0 ·
CRASH4-6874 avatar image CRASH4-6874 AnuragSingh-MSFT ·

Hi Anurag,
Sorry for the delayed reply. Thank you for your response. Pls find my response below for each points mentioned above:
1. File Path is not huge, file is under root folder on the SFTP server and the content of the file is "Hello World". The List Folder Action response confirms the same as below:
[
{
"Id": "L1BSSU5ET05FU0lTRlRQL3NhbXBsZS50eHQ=",
"Name": "sample.txt",
"DisplayName": "sample.txt",
"Path": "/ROOTFOLDER/sample.txt",
"LastModified": "2022-03-15T06:30:26Z",
"Size": 13,
"MediaType": "text/plain",
"IsFolder": false,
"ETag": "\"MDMvMTUvMjAyMiAwNjozMDoyNnwxMw==\"",
"FileLocator": "L1BSSU5ET05FU0lTRlRQL3NhbXBsZS50eHQ=",
"LastModifiedBy": null
}
]
2. The SFTP Action configurations looks good:

  1. There are no specials characters as you could see above

  2. Yes, due to some reason, get file content is not allowed from the server. However, I could see the below page mentions the connector has a limitation with GXS SFTP server, which is what we are trying to connect.
    https://docs.microsoft.com/en-us/azure/connectors/connectors-sftp-ssh

As per my understanding, the connector is internally using SSH library, which is the same I am using with in a Function as an alternative approach. As mentioned previously, the function (consumption plan) is able to list, create, delete and Read the content from the remote SFTP server.

0 Votes 0 ·

Hi Anurag @AnuragSingh-MSFT ,
Sorry for the delayed reply. Thank you for your response. Pls find my response below for each points mentioned above:

  1. File Path is not huge, file is under root folder on the SFTP server and the content of the file is "Hello World". The List Folder Action response confirms the same as below:
    [
    {
    "Id": "L1BSSU5ET05FU0lTRlRQL3NhbXBsZS50eHQ=",
    "Name": "sample.txt",
    "DisplayName": "sample.txt",
    "Path": "/ROOTFOLDER/sample.txt",
    "LastModified": "2022-03-15T06:30:26Z",
    "Size": 13,
    "MediaType": "text/plain",
    "IsFolder": false,
    "ETag": "\"MDMvMTUvMjAyMiAwNjozMDoyNnwxMw==\"",
    "FileLocator": "L1BSSU5ET05FU0lTRlRQL3NhbXBsZS50eHQ=",
    "LastModifiedBy": null
    }
    ]

  2. The SFTP Action configurations looks good:
    183165-image.png

  3. There are no specials characters as you could see above

  4. Yes, due to some reason, get file content is not allowed from the server. However, I could see the below page mentions the connector has a limitation with GXS SFTP server, which is what we are trying to connect.
    https://docs.microsoft.com/en-us/azure/connectors/connectors-sftp-ssh

As per my understanding, the connector is internally using SSH library, which is the same I am using with in a Function as an alternative approach. As mentioned previously, the function (consumption plan) is able to list, create, delete and Read the content from the remote SFTP server. Pls advise for any additonl info


0 Votes 0 ·
sftp-connecotr.png (31.4 KiB)

@CRASH4-6874, thank you for the reply. As confirmed in your post above, you are using GXS SFTP server which is not supported with this connector. I am not sure of the internal implementation/library being used with this connector, however based on the published doc we are hitting an unsupported scenario. Therefore, the current solution for this scenario would be to use inline code or to trigger Function App from your Logic Apps (as already being used by you). I regret the inconvenience this is causing you.

I would also request you to submit feedback to our Logic Apps teams using this link.

0 Votes 0 ·