Once you 've setup a virtual machine in Windows Azure, you are likely need to transfer files between your local machine and the virtual machine in the cloud. you may need to upload software, tools or even database files to the VM.
The most convenient way to do that is to have a FTP server on the VM, so you can do uploading and downloading from anywhere.
However, set up a FTP server in the cloud is not as easy as it looks like. The key challenge is that FTP sessions need to establish two connections to transfer a file:
- Control connection. Used to send control between server and client. established when client connect to server on port 21;
- Data Connection. used to transfer files. In active mode, client randomly picks a port and server will make the connection; in passive mode, server randomly picks a port, and client makes the connection.
As you know, VM does not have public IP address, to make the virtual machine accessible from outside of cloud, you need to create an endpoint for each port you want to connect, to forward the port from public gateway to your VM.
That means, if you want to connect to port 21 of the VM, you need to create an endpoint in the Windows azure portal, to forward port 21 to VM's port 21. that's relative easy, What's difficult is the data channel, because we don't know the exact ports beforehand.
So we have to limit the ports that FTP server uses for data channel to a small range, and for each port in the range, create an endpoint, so that client and server can establish the data connection.
Also, don't forget firewall. Make sure the firewall on the server allows connection on the ports (21 and ports for data channel ).
Below are the detailed steps (by default the actions are done on Windows azure virtual machine, not your local machine ):
1, download filezilla server from http://filezilla-project.org/download.php? Type = server;
2. Install filezilla server, accept all the default options;
3. Add a user
3.1 launch filezilla server interface;
3.2 go to menu edit-> users;
3.3 click the Add button in the Users Group on the right side;
3.4 select shared folders in the page group, on the left;
3.5 In the shared folders, click the Add button, select a folder that FTP user can access;
3.6 Click OK to close the dialog;
More Info http://wiki.uniformserver.com/index.php/FileZilla_Server:_Basic_Configuration
Now you shoshould be able connect to the FTP server from within the virtual machine, use the user you just created. But it's not accessible outside of the VM, like from your desktop.
4. Configure Firewall to allow "filezilla server.exe", not "filezilla server interface.exe", through;
5. Configure your virtual machine to allow FTP connection
5.1 go to your windowsazure.com portal;
5.2 select your virtual machine, and click endpoints on the top;
5.3 clicking Add endpoint button on the bottom;
5.4 put following parameter in to popped Dialog
Name: <whatever you want>
Protocal: TCP
Public port: 21
Private Port: 21
More Info http://www.windowsazure.com/en-us/manage/windows/how-to-guides/setup-endpoints/
Now you shoshould able to log in to the FTP server from anywhere, but still unable to retrieve directory listing, because you can't establish the data connection.
6. Configure Data Channel port in filezilla Server
6.1 launch filezilla server interface;
6.2 go to menu edit-> setting;
6.3 select passive mode setting on the left
6.4 check "use M m port range", and input a port number greater than 1024 for both low and high number, let's say put 60000. (limit the port range because we don't want to create hundreds or thousands of endpoint in windowsazure portal );
6.5 Click OK to close the dialog;
7. Configure Firewall to Allow inbound connection from the port configured in Step 6;
8. Add another endpoint in the windowsazure portal for the Data Channel port you configured in step 6, parameters:
Name: <whatever you want>
Protocal: TCP
Pubport: 60000
Private Port: 60000
9, in the IPv4 specific group, select retrieve external IP address from:
Filezilla_passive_setting
Done!
Note: Windows Command Line ftp.exe does not support passive mode, so recommend filezilla client to connect from outside of the virtual machine.
Address: http://huberyy.wordpress.com/2012/08/03/set-up-a-ftp-server-in-windows-azure-virtual-machine-with-filezilla-no-coding/