So you have a big complicated Minecraft world built up and you want to share it with your friends, huh? Initially, you’ll just turn your home computer into a Minecraft Server,
setup port-forwarding on your router and then share the IP address with your friends. What about that open port letting worms in? What about your home computer being too slow so
that the play is lagging? What about not being able to do anything else with your computer while your friends are exploring your world. Well, maybe you get a bright idea to host
your server somewhere else … like on the cloud. I am going to talk about hosting it on Azure.
First of all the reference for setting up the server itself is found in the Minecraft Wiki
At this point, I am wondering if your first reaction is that we are obviously going to setup this server as a Virtual Machine Role on Azure. Those were my initial thoughts as
well. You simply create a VHD locally, install the server manually and then when it is all ready and to your liking, you deploy it to the cloud, turn it on and voila: a working
server. No, we are going to do something much bolder, we’re going to start with stock Worker Role and install what we need dynamically to get to the same endpoint. Why? To avoid
having to maintain the VHD with differencing disks, and to have hope that we can serve up multiple worlds at the same time.
Moving on we are going to need the correct port number in the service definition.
<?xml version=”1.0″ encoding=”utf-8″?>
<ServiceDefinition name=”MineCraft” xmlns=”http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition”>
<Setting name=”DiagnosticsConnectionString” />
<InputEndpoint name=”GameEndpoint” protocol=”tcp” port=”25565″ />
Now what about the IP address? Don’t even think about having a static IP! You can’t have that yet on Azure. We are going to have to settle for a dynamic IP. Once the server starts
it can determine what IP address it has and publish it somewhere and then you can give the address to your friends. So you’ll have this kind of code running in the worker-role.
You need to create a listener that connects to the load-balancer.
TcpListener listener = new TcpListener(
This is one way to determine the IP upon startup of the web role.
public class WebRole : RoleEntryPoint
public override void Run()
string ipAddress = “”;
if (RoleEnvironment.CurrentRoleInstance.UpdateDomain == 0)
ipAddress = GetExternalIp();
public string GetExternalIp()
string whatIsMyIp = “http://automation.whatismyip.com/n09230945.asp”;
WebClient wc = new WebClient();
UTF8Encoding utf8 = new UTF8Encoding();
string text = “”; //Get the Web Role’s IP address using WhatIsMyIP.com
text = utf8.GetString(wc.DownloadData(whatIsMyIp));
IPAddress externalIp = IPAddress.Parse(text);
You are going to need Java. Download java from http://javadl.sun.com/webapps/download/AutoDL?BundleId=63692
To install java in the startup silently use the following command line.
jre-7u4-windows-x64.exe /s INSTALLDIR=C:\Java
To be continued …