Can Azure Functions use FTP to copy a file to an Azure VM?

Adrian Griffith 61 Reputation points
2022-03-21T13:57:42.573+00:00

Can I use the FTP protocol (through a hybrid connection) to copy files from an Azure File share to an Azure virtual machine?

I am attempting to find some means for an Azure Function to copy a file to an Azure Virtual Machine. Copying a file using SMB to a non-Azure storage source (not Azure File Shares or Blobs) is not possible due the the Azure app sandbox. https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#file-system-restrictionsconsiderations

So I have attempted to use FTP over a Hybrid Connection for port 21. I thought this would work. FTP/SFTP/FTPS are socket based (like SQL Server). That is what hybrid connections are to provide. A means for socket based communication without opening your firewall.

This works locally off my desktop. This does not work in Azure. I get the following error and there appears to not be a dang thing I can do to correct it.

Should this work?

Thanks

The server committed a protocol violation at System.Net.FtpWebRequest.SyncRequestCallback(Object obj)
at System.Net.CommandStream.InvokeRequestCallback(Object obj)
at System.Net.CommandStream.Abort(Exception e)
at System.Net.FtpWebRequest.FinishRequestStage(RequestStage stage)
at System.Net.FtpWebRequest.GetResponse()
at ProcessSalesforceData.Manager.Repositories.FtpStorageRepository.CopyAsync(String sourcePathAndFile, String destinationPathAndFile, String fileShare) in D:\a\8\s\Production\Services\ProcessSalesforceData\trunk\ProcessSalesforceData.Manager\Repositories\FtpStorageRepository.cs:line 56
at ProcessSalesforceData.Manager.FileStorageManager.CopyAsync(QueueRequest queueRequest, ProjectInformation projectInfo) in D:\a\8\s\Production\Services\ProcessSalesforceData\trunk\ProcessSalesforceData.Manager\FileStorageManager.cs:line 41
at ProcessSalesforceData.Manager.ProcessRequestManager.ProcessRequestAsync(QueueRequest queueRequest) in D:\a\8\s\Production\Services\ProcessSalesforceData\trunk\ProcessSalesforceData.Manager\ProcessRequestManager.cs:line 54

This is a certificate problem (for which I have no control over): RemoteCertificateNameMismatch, I respond with true. This works locally but not as an Azure Function. Maybe we are just not ready to move to the cloud.

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,169 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,298 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,157 questions
0 comments No comments
{count} votes

Accepted answer
  1. deherman-MSFT 33,626 Reputation points Microsoft Employee
    2022-03-29T18:44:17.557+00:00

    @Adrian Griffith
    Apologies for the delay responding here. I understand you are attempting to copy a file from Azure Files to an Azure VM.

    I am not sure I am understanding the need to use FTP here. If you have Azure Files setup is there a reason you cannot directly mount from the VM and copy the file that way? You can also consider downloading the file using AzCopy. Other methods are using the SDK to copy the file.

    Resources:
    How to connect and place a file on an azure virtal machine from azure function apps?
    Azure Function, Blob Trigger : Copy data file from blob to a server
    How to copy the blob from the Azure storage to linux virtual machine using python?
    Copy files from Azure Blob storage to Azure File Storage with Azure functions

    Hope this helps. Let us know if you run into any issues or have further questions.

    -------------------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


0 additional answers

Sort by: Most helpful