I'm trying to FTP a file from Azure up to some FTP destination.
When I do it locally, it's working great. Ok ...
I publish this webjob up to azure and it's works great until it tries to do the FTP bit.
The following error is shown:
[12/21/2015 03:18:03 > 944464: INFO] 2015-12-21 03:18:03.6127| ERROR| Unable to connect to the remote server. Stack Trace: at System.Net.WebClient.UploadFile(Uri address, String method, String fileName)
[12/21/2015 03:18:03 > 944464: INFO] at System.Net.WebClient.UploadFile(String address, String method, String fileName)
And this is my simple code...
public void UploadFile(FileInfo fileInfo)
{
try
{
using (var client = new WebClient())
{
var destination = new Uri($"ftp://{_server}/{fileInfo.Name}");
client.Credentials = new NetworkCredential(_username, _password);
client.UploadFile(destination, "STOR", fileInfo.FullName);
}
}
catch (Exception exception)
{
// snipped.
throw;
}
}
So it's pretty damn simple.
Could this be some weird PASSIVE/ACTIVE issue? Like, how our office internet is simple while azure's setup is complex and ... as such ... it just cannot create the FTP connection?
Now - this is where things also get frustrating. Originally I was using a 3rd party FTP library and that DID work .. but some files were only getting partially uploaded .. which is why i'm trying to use WebClient
instead. So I know that my azure webjob "website" thingy can FTP up. (no blocked ports, etc).
Any clues to what I can do, here?