我在工作中使用 DataFactory。
我正在考虑将文件从 Blob 存储传输到本地 FTP 服务器,但是有没有好的方法来实现它?
当我研究它时,我发现了逻辑应用程序、Azure Functions 和自定义活动,但我想知道是否有更简单的方法来实现它......
根据this,我们无法直接使用ADF将文件从blob存储写入FTP服务器。您可以利用 Azure Functions 将数据从 Azure Blob 存储复制到本地 FTP 服务器。
您可以使用以下代码:
public void UploadStreamToFtp(Stream file, string targetFilePath)
{
using (MemoryStream ms = new MemoryStream())
{
// As MemoryStream already handles ToArray(), copy the Stream to the MemoryStream
file.CopyTo(ms);
using (WebClient client = new WebClient())
{
// Use login credentials if required
client.Credentials = new NetworkCredential("username", "password");
// Upload the stream as Data with the STOR method call
// targetFilePath is a fully qualified filepath on the FTP, e.g. ftp://targetserver/directory/filename.ext
client.UploadData(targetFilePath, WebRequestMethods.Ftp.UploadFile, ms.ToArray());
}
}
}
欲了解更多信息,您可以参考这个SO答案。