我正在使用Azure functions2.0,我需要从CosmosDB获取文档,将其格式化为单个CSV文件,并将其上传到SFTP位置。
我能够通过CosmosDB输入绑定查询和获取文档,并且可能会使用CSVHelper库来处理CSV格式。但我似乎找不到SFTP输出绑定。我查过了:
显然,以前有一个外部文件触发器/绑定已被弃用(Corrupt file when using Azure Functions External File binding)
从Azure函数将文件流式上传到SFTP位置的最佳方式是什么?
发布于 2019-10-17 09:42:10
根据我的研究,目前Azure函数不提供SFTP绑定。因此,如果你想上传文件到SFTP服务器,你需要用你的代码实现ii。关于如何实现它,您可以使用Renci.SshNet.Async。例如
string host = ""; // your server name
int port =22 ;// your port
string username ="";// your sftp server username
string password="";// your sftp server password
SftpClient client = new SftpClient(host, port, username, password);
client.Connect();
string path = "";// The file to write to
byte[] bytes = Encoding.UTF8.GetBytes("test");
client.WriteAllBytes(path, bytes);
client.Dispose();
client.Disconnect();https://stackoverflow.com/questions/58415948
复制相似问题