首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从Azure函数上载文件到SFTP位置

从Azure函数上载文件到SFTP位置
EN

Stack Overflow用户
提问于 2019-10-16 22:39:55
回答 1查看 2.4K关注 0票数 0

我正在使用Azure functions2.0,我需要从CosmosDB获取文档,将其格式化为单个CSV文件,并将其上传到SFTP位置。

我能够通过CosmosDB输入绑定查询和获取文档,并且可能会使用CSVHelper库来处理CSV格式。但我似乎找不到SFTP输出绑定。我查过了:

https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#supported-bindings

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob?tabs=csharp#output

显然,以前有一个外部文件触发器/绑定已被弃用(Corrupt file when using Azure Functions External File binding)

从Azure函数将文件流式上传到SFTP位置的最佳方式是什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-17 09:42:10

根据我的研究,目前Azure函数不提供SFTP绑定。因此,如果你想上传文件到SFTP服务器,你需要用你的代码实现ii。关于如何实现它,您可以使用Renci.SshNet.Async。例如

代码语言:javascript
复制
            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();
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58415948

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档