无法从 Azure Automation Powershell 脚本连接到本地计算机 FTP 服务器

Unable to connect to local machine FTP server from Azure Automation Powershell script

我是 FTP 和 Powershell 的新手。如前所述,我已经在我的本地机器上设置了一个 FTP 服务器:here .. 我正在尝试从 Powershell 脚本向它上传文件,我已经从我的本地机器上成功了。

但是当我尝试从 Azure 自动化 运行 脚本时,我得到:"Unable to connect to the remote server" 错误。我还尝试将我的脚本启用为 shown here

的被动模式

我还尝试在网络驱动器上为所有用户共享我的 ftp 文件夹,禁用所有防火墙,使用我的 public IP 地址和完整数据通道在 IIS 中设置 FTP 防火墙支持端口范围,但我仍然得到同样的错误。请帮忙。

你想实现这个吗?

如果是,根据你的情况,我建议你最好使用WinRM而不是FTP你的服务器。当您的 WinRM 您的服务器时,您可以像本地 PC 一样调用命令。

1.Configure 您的本地 FTP 服务器允许远程 WinRM,请参考此 link

2.Connect 您在 Azure 上的服务器通过非交互式登录实现自动化。只需使用以下 cmdlet。

$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)

请注意,您可能必须在自己的计算机上设置受信任的主机,以信任 Azure 计算机来创建 winrm 会话。这可以通过以下方式完成:Set-Item WSMan:localhost\Client\TrustedHosts -value * -Force

另外,你可以参考这个

我无法在我的本地计算机上运行 WinRM 解决方案,我会在完成后进行更新。但我认为提到的 Azure 混合 Runbook Worker 可能是一个很好的解决方案。我仍然必须尝试一下。目前,我已将 FTP 添加到我的 Azure VM 并使其可行。