-1

I am new to FTP and Powershell. I have setup an FTP server on my local machine as mentioned : here .. I'm trying to upload files to it from a Powershell script and I have succeeded from my local machine.

But when I try to run the script from Azure Automation, I get: "Unable to connect to the remote server" error . I also tried my script to enable Passive Mode as shown here

I also tried sharing my ftp folder on network drive for all users, disabled all firewalls, setup FTP Firewall Support in IIS with my public IP address and full data channel port range, but I still get the same error. Please help.

Community
  • 1
  • 1
Payal
  • 73
  • 2
  • 13
  • " I try to run the script from Azure Automation" : Clarify your intention, elaborate your network connection setup. – mootmoot Apr 06 '17 at 07:55
  • I suggest you could WinRM your FTP server instead of FTP it. When you connect your Server, you could invoke commands. – Shui shengbao Apr 06 '17 at 08:45
  • Do you want to achieve this [question](http://stackoverflow.com/questions/43209366/how-to-download-a-blob-file-from-azure-storage-and-save-it-to-an-ftp-server-usin)? – Shui shengbao Apr 06 '17 at 08:49
  • Yes, I'm trying to achieve this question. – Payal Apr 06 '17 at 16:08

2 Answers2

1

Do you want to achieve this question:How to download a blob file from Azure Storage and save it to an FTP server using Powershell??

If yes, according to your scenario, I suggest you had better use WinRM instead of FTP your server. When your WinRM your server, you could invoke commands just like your local PC.

1.Configure your local FTP server to allow WinRM remotely, please refer to this link.

2.Connect your Server on Azure automation with non-interactive login. Just use the following cmdlets.

$username = '<admin-user>'
$pass = ConvertTo-SecureString -string '<password>' -AsPlainText -Force
$cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $pass
Enter-PSSession -ComputerName <public-IP> -Credential $cred -SessionOption (New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck)

Note that you may have to set your trusted hosts on your own computer to trust the Azure machine to create the winrm session. This can be done with something like: Set-Item WSMan:localhost\Client\TrustedHosts -value * -Force

Also, you could refer to this answer.

Community
  • 1
  • 1
Shui shengbao
  • 18,746
  • 3
  • 27
  • 45
  • After you Winrm your FTP server, you could download blobs to your FTP server with PowerShell cmdlets. – Shui shengbao Apr 06 '17 at 09:11
  • Thank you, I'm trying this out. I have one question related to TrustedHosts. How do I know the computer name if I don't have any Azure VM? I only have some scripts running from Azure Automation? – Payal Apr 06 '17 at 16:03
  • So you mean that after setting this up, i can use the FTP Powershell cmdlets like [here](http://stackoverflow.com/questions/1867385/upload-files-with-ftp-using-powershell)? – Payal Apr 06 '17 at 16:06
  • @Payal You could control your Server as local PC. – Shui shengbao Apr 07 '17 at 00:56
  • @Payal You don't have Azure VM. It is just an example. They are same, if your FTP Server could be exposed to Public Internet, you could use this way. `ComputerName` is your server Public IP. – Shui shengbao Apr 07 '17 at 00:57
  • Hi, does it work? If you had other question, please ask here. – Shui shengbao Apr 07 '17 at 06:41
  • that did not work. I started WinrM on my local machine as in the link above. But when I enable PSRemoting at the top of my azure automation powershell script, I get error saying that Could not check WinRM status. I am not sure what that means, because my local WinRM status shows running in local Powershell. And how can I check the Azure Portal's WinRM status? – Payal Apr 07 '17 at 06:59
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/140145/discussion-between-walter-msft-and-payal). – Shui shengbao Apr 07 '17 at 07:00
  • One other thing that I am trying now is to add FTP Server on another client Azure VM, and I am trying to call that machine from another Azure account automation powershell script. I am able to call the VM FTP Server from local Filezilla and upload/download files, but from the Azure script, I get this error: The remote server returned an error: (550) File unavailable (e.g., file not found, no access). In this case it is definitely no access issue, but what do I need to do for this? Is it still related to the same PSRemoting issue? PSRemoting is disabled here. – Payal Apr 07 '17 at 07:03
1

I haven't been able to make the WinRM solution work from my local machine, and I'll update once I do. But I think that Azure's Hybrid Runbook Worker as mentioned here maybe a good solution. I still have to try that too. Currently I have added FTP to my Azure VM and made this workable.

Community
  • 1
  • 1
Payal
  • 73
  • 2
  • 13