title: Uploading file with FtpWebRequest from an azure hosted application to an external ftp site
body: <blockquote>
    <p><strong>UPDATE: I found out that it is not an issue with azure rather the
    other party who are actually doing white-listing on incoming
    connection.</strong></p>
  </blockquote>
  
  <p>I implemented a service, which open and ftp connection to upload a file to a remote FTP server. <strong>The code works perfectly (!) running on my desktop, however if I publish it to the azure hosting cloud and execute with exactly the same parameters I get WebException with the message 'The remote server returned an error: (530) Not logged in.'</strong> I haven't found any relevant setting in the azure console. I also tried different setting like on/off keep-alive and passive, but the result are the same. Do you guys have an idea what could be the problem?</p>
  
  <p>The code for reference:</p>
  
  <pre><code>            Dim request As FtpWebRequest
  
              request = TryCast(WebRequest.Create($"ftp://{_host}/inventory/{_uploadFilename}"), FtpWebRequest)
              request.Method = WebRequestMethods.Ftp.UploadFile
              request.Credentials = New NetworkCredential(_username, _password)
              request.UsePassive = True
              request.UseBinary = True
              request.KeepAlive = False
  
              Using fs As FileStream = File.OpenRead(_fileName)
                  Dim buffer As Byte() = New Byte(fs.Length - 1) {}
                  fs.Read(buffer, 0, buffer.Length)
                  fs.Close()
                  Dim requestStream As Stream = request.GetRequestStream()
                  requestStream.Write(buffer, 0, buffer.Length)
                  requestStream.Flush()
                  requestStream.Close()
  
  
                  Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
                  Return Ok($"Remote server response: {response.StatusDescription}")
  
              End Using
  </code></pre>