gpt4 book ai didi

azure - 如何从 Azure webjob 访问共享网络驱动器

转载 作者:行者123 更新时间:2023-12-03 02:55:11 25 4
gpt4 key购买 nike

尝试使用 Web 作业中的 UNC 路径访问共享网络驱动器时出现访问被拒绝错误。我正在尝试从客户端服务器上的共享文件夹和 SFTP 读取文件。从本地,它工作正常,能够访问所有文件。但从 Azure Web 作业中,文件夹出现访问被拒绝错误。这是我的代码:

 var con = new ConnectionInfo(host, 22, username, methods.ToArray());
using (var client = new SftpClient(con))
{
Console.WriteLine("Connecting to client");
client.Connect();
Console.WriteLine("Connected to client");
Console.WriteLine("Getting file from Azure ");
string tstkey1 = File.ReadAllText(@"\\{shared folder}\test\test.txt");
Console.WriteLine("Connected");
string tstkey = File.ReadAllText(@"\\{shared folder}\test\test.txt");
Console.WriteLine(tstkey);
byte[] fileContents = Encoding.UTF8.GetBytes(tstkey);
Stream requestStream = new MemoryStream(fileContents);
Console.WriteLine(requestStream);
Console.WriteLine("Uploading to FILE to client SFTP");
client.UploadFile(requestStream, "/inbound/STEIN366_ACH_1/*.*" + "Test");
client.Disconnect();
Console.WriteLine("Deleting File");
File.Delete(@"\\{folder}\test\test.txt");
Console.WriteLine("Dissconnected from client");
}

有人可以帮助我,如何从 Azure 连接到共享文件夹!提前致谢。

最佳答案

如果您想使用 SFTP 传输文件,您可以使用 WinSCP .NET Assembly

这是guide使用WinSCP。你可以引用这个answer关于 WinSCP 使用。

如果您仍有疑问,请告诉我。

关于azure - 如何从 Azure webjob 访问共享网络驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53419080/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com