[英]Upload file to SFTP location from Azure Function
我正在使用 Azure Functions 2.0,我需要從 CosmosDB 獲取文檔,將它們格式化為單個 CSV 文件並將其上傳到 SFTP 位置。
我能夠通過 CosmosDB 輸入綁定查詢和獲取文檔,並且可能會使用 CSVHelper 庫來處理 CSV 格式。 但我似乎找不到 SFTP output 綁定。 我檢查過:
顯然,曾經有一個外部文件觸發器/綁定已被棄用( 使用 Azure 函數外部文件綁定時損壞的文件)
ZF7B44CFFAFD5C52223D5498196C8A2E7BZ 將文件從 Azure Function 上傳到 SFTP 位置的最佳方法是什么?
根據我的研究,目前 Azure function 不提供 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();
我正在 Azure 函數中從事類似的項目,並且正在使用 Rebex.Sftp 庫進行文件傳輸。 到目前為止,它很容易使用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.