Getting access denied error when am trying to access shared network drive using UNC path from web job. Am trying to read a file from shared folder and SFTP on client-server. From local, it is working fine being able to access all files. But from azure web job getting access denied error to folder. Here is my code :
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");
}
Can someone help me, how to connect to the shared folder from Azure! Thanks in advance.