SFTP Script task not Working in Azure Integration service

Md. Muzahid Sarker 1 Reputation point
2021-02-09T03:53:45.743+00:00

Hi All,

I create a ETL package to download data from SFTP server to Azure blob and load that file into a data warehouse. To complete this task i create a C# script task with SSH.net DLL file. when i run this application from my local machine its work fine. But when i deploy my ETL package into Azure integration service the code not working.
Every time i run from Azure integration service i m getting below error .

"Script Task:Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at Renci.SshNet.Abstractions.SocketAbstraction.Connect(IPEndPoint remoteEndpoint, TimeSpan connectTimeout)
at Renci.SshNet.Session.SocketConnect(String host, Int32 port)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at ST_c843d17ae6354854b7e946cb80e158c9.ScriptMain.Main()"

Azure support team inform me the relation between azure and SFTP have no issue the issue is in my code. But i m unable to find any issue in my code. below is my code

 try
            {
                String Host = sftp address;
                int Port = 22;
                string DownloadDirectory =  download folder;

                if (!Directory.Exists(DownloadDirectory))
                {

                    System.IO.Directory.CreateDirectory(DownloadDirectory);

                }
                String Username = username;
                String Password = password;

                string remoteDirectory = sftp folder path;

                using (var sftp = new SftpClient(Host, Port, Username, Password))
                {
                    sftp.Connect();

                    var files = sftp.ListDirectory(remoteDirectory);

                    foreach (var file in files)
                    {
                        string remoteFileName = file.Name;

                            if (File.Exists(DownloadDirectory + remoteFileName))
                            {
                                File.Delete(DownloadDirectory + remoteFileName);
                            }

                            using (Stream file1 = File.OpenWrite(DownloadDirectory + remoteFileName))
                            {
                                sftp.DownloadFile(remoteDirectory + remoteFileName, file1);
                            }                    
                    }

                    sftp.Disconnect();
                }
            }
            catch (Exception ex)
            {

                Console.Write(ex.Message);

            }

Thanks for your help. I'm not sure if i put correct tag or not.

Md. Muzahid Sarker

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,459 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Monalv-MSFT 5,896 Reputation points
    2021-02-09T07:20:51.277+00:00

    Hi @Md. Muzahid Sarker ,

    Script Task:Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

    Please refer to the following links:

    1.SSIS Sql Agent Job : Could Not connect error

    2.SSMS – Azure Storage Error – A Connection Attempt Failed Because the Connected Party did not Properly Respond After a Period of Time
    If this is a Virtual Machine in Azure, then check if Internet “outbound” is blocked on the server. Actually, to reproduce the error I blocked it.
    Check if there is any proxy server which is coming in between.
    Check for any possible firewall which is blocking connection to the storage account.

    Best Regards,
    Mona

    ----------

    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Md. Muzahid Sarker 1 Reputation point
    2021-02-14T03:23:20.13+00:00

    Hi @Monalv-MSFT ,

    Thanks for you update. Still i haven't got any update from Network support team. I inform them to check outbound firewall block or not. Also I ask them if its VM machine and if i can remote login to run my code.

    Still i m waiting for support team response. I will update if i can solve this issue and what response i got for Azure team.

    Thanks
    Muzahid


  3. Md. Muzahid Sarker 1 Reputation point
    2021-02-27T04:41:25.387+00:00

    Hi @Monalv-MSFT ,

    So far still no Update. Right now we are creating a Dev environment in Azure with Remote login. After that we r going to debug our Code that system.
    I can't find any 100% Correct solution yet. I will Update this post as soon as I successfully complete any stage.

    Best Regards,
    Muzahid Sarker

    0 comments No comments