简体   繁体   English

尝试从 Azure 应用服务连接到 FTP 服务器

[英]Trying to connect to an FTP server from Azure App service

I am trying to upload/download some files from Azure VM directly through a Azure App service, but the app returns this error:我正在尝试通过 Azure App 服务直接从 Azure VM 上传/下载一些文件,但该应用程序返回此错误:

System.Net.WebException: The remote server returned an error: (501) Syntax error in parameters or arguments. System.Net.WebException:远程服务器返回错误:(501)参数或参数中的语法错误。

I am using blazor and this is the code from the that I use to upload:我正在使用 blazor,这是我用来上传的代码:

{
    // Get the object used to communicate with the server.
    FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://xxx.xxx.xxx.xxx/dir/file.conf");
    request.Method = WebRequestMethods.Ftp.UploadFile;
    request.UsePassive = false;
    request.Credentials = new NetworkCredential("xxxx", "xxxx");

    // convert contents to byte.
    byte[] fileContents = Encoding.ASCII.GetBytes(str); ;

    request.ContentLength = fileContents.Length;

    using (Stream requestStream = request.GetRequestStream())
    {
        requestStream.Write(fileContents, 0, fileContents.Length);
    }

    using (FtpWebResponse response = (FtpWebResponse)request.GetResponse())
    {
        Console.WriteLine($"Upload File Complete, status {response.StatusDescription}");
    }
}

If I do try from my PC it works properly.如果我确实从我的电脑上尝试它可以正常工作。

  • There could be several reasons for the FTP issue, the exact error message may provide some pointers. FTP 问题可能有多种原因,确切的错误消息可能会提供一些指示。
  • Azure App Service supports connecting via both Active and Passive mode. Azure 应用服务支持通过主动和被动模式进行连接。 Passive mode is preferred because your deployment machines are usually behind a firewall.被动模式是首选,因为您的部署机器通常位于防火墙后面。
  • If you set UsePassive to false, then you need to make sure that the port for the command channel is open (ie, you need to define endpoints and access rules).如果您将 UsePassive 设置为 false,那么您需要确保命令通道的端口是开放的(即,您需要定义端点和访问规则)。 Unless there is a good reason to not use passive, you are far better off using passive.除非有充分的理由不使用被动,否则最好使用被动。
  • Refer this document for more information:有关更多信息,请参阅此文档:
    Deploy your app to Azure App Service using FTP/S 使用 FTP/S 将应用部署到 Azure 应用服务
  • You can also copy files directly from Kudu console to local: http://yourwebappname.scm.azurewebsites.net/ (Add'scm' to the default WebApps mentioned above)您也可以直接从 Kudu 控制台复制文件到本地:http: //yourwebappname.scm.azurewebsites.net/ (将'scm'添加到上面提到的默认WebApps)
  • Go to the cmd button and look in the site/wwwroot folder for your project files.转到 cmd 按钮并在 site/wwwroot 文件夹中查找您的项目文件。
  • You could also use VS team explorer to clone the WebApp from Azure App Service to your local Visual Studio (VS).您还可以使用 VS 团队资源管理器将 WebApp 从 Azure 应用服务克隆到本地 Visual Studio (VS)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法通过免费的Azure应用服务连接到远程SFTP服务器 - Unable to connect to a remote SFTP server from a Free Azure app service 从 Azure 中托管的应用程序读取 FTP 服务器 - Read FTP server from app Hosted in Azure FTP Azure 应用服务到本地服务器上的文件夹 - FTP out of Azure App Service to folder on on premise server 尝试连接到(localdb)而不是Azure SQL的Azure云服务应用 - Azure Cloud Service App trying to connect to (localdb) instead of Azure SQL 使用Azure App Service中的Powershell命令连接到Azure AD - Connect to Azure AD using Powershell commands from Azure App Service Azure云服务嵌入式FTP服务器 - Azure cloud service embedded FTP server Azure App服务无需内部连接即可在内部连接到SQL Server - Azure App service connect to SQL Server on premise without hybrid connection 从Azure Web应用连接到Prem SQL Server - Connect to On Prem SQL server from Azure Web app Azure asp.net web 应用程序尝试连接到 Z30162ED78B6C10F731411F2FC4F - Azure asp.net web app trying to connect to Oracle runtime integration linked service 尝试连接到Azure Web App的授权错误 - Authorization error trying to connect to Azure Web App
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM