Deploying Minecraft Server on Azure

The Azure Marketplace now has a Minecraft Server offering which deploys a customizable Minecraft Server to an Azure virtual machine. This replaces an older Azure Gallery Minecraft item which was often out of date, sometimes broken, and eventually removed.

The new solution template creates an Azure virtual machine running Ubuntu 16.04 and installs Minecraft Server running on it. It also creates the other cloud infrastructure components you need, including: a resource group, virtual network, public IP address, DNS name, network security group (NSG). Additionally it lets you set several Minecraft server configuration parameters at deployment time. What follows is a brief user guide covering how to deploy and operate your Minecraft Server running in Azure.

For a Spanish guide to deploying a Minecraft server in Azure, go here: Cómo crear un servidor Minecraft en Azure (thanks @platter5_).

What you need to get started

Finding the Minecraft Server

You can deploy the Minecraft Server Marketplace solution to a new VM directly from the Azure Marketplace or by searching for it from the Azure portal.

From the Marketplace

Go to the Minecraft server Marketplace product page and click GET IT NOW.

image

From there click Continue and you’ll be taken to the Azure portal..

From the Portal

You can also deploy the Minecraft Server directly from the Azure Portal. Click the ‘+’ sign and type “minecraft” in the search.

image

Deploying the Minecraft Server

Once you’ve selected the Minecraft Server product in the portal you’ll see a description and a Create button.

Click Create.

From here the portal takes you through a set of forms known as portal blades to configure the deployment. Let’s go through them one by one:

Basics

image

VM username – A Linux user name you’ll use if you need to log on to the virtual machine.

Password – The password you’ll use if you need to log on to the virtual machine. Don’t forget this.

Subscription – If you have access to more than one Azure subscription, choose the one you want to use for this deployment.

Resource group – A logical container for your resources. It’s a good idea to create a new one here, that way if you want to remove everything you created at some point you can simply delete the resource group and it won’t affect any other deployments.

Location – Pick the region where the resources will be created. Picking somewhere local to you is usually a good idea to minimize network round-trip time.

Click OK.

Virtual Machine Settings

image

Public IP address resource name – Leave the default setting.

Domain name label – Pick a unique domain name for your server. No punctuation, spaces etc., just letters and/or numbers. Later when you connect to this server the full domain name will be like: ..cloudapp.azure.com.

Size – The size of the virtual machine. You can accept the default or choose a larger machine with more CPU/memory, but it is not recommended to choose a smaller machine like A0 or D0. If you do pick a smaller VM size the server might get a bit laggy.

Click OK.

Minecraft Server Settings

image

Minecraft username – This is your Minecraft username – get it right or you won’t be an operator of the Minecraft server that gets created. Don’t put an email address or anything else, except a valid Minecraft username.

Minecraft server version – This should default to the latest version of the Minecraft server and hence not need changing. The field is editable just in case a new server version comes out and the Azure Marketplace product hasn’t been updated yet. If there is a new server version available you can put it here.

difficulty – The default Difficulty of 1 means peaceful mode. Check here for what values you can use for this and the next few parameters: http://minecraft.gamepedia.com/Server.properties

level-name – Whatever you want your new Minecraft world to be called or leave the default value. Don’t use any special characters which could interfere with a bash script. E.g. no spaces, single quotes, explanation marks, backslashes (unless you’re deliberately escaping a character).

game-mode – The default value is 0 – Survival mode. 1 is creative.

white-list – Set this to true to make this invite-only. Initially only you would have access, and for people to join you’ll have to use operator commands to add them to the white-list.

enable-command-block – If this is true you can create command blocks in the server, which empowers you to build a near limitless array of quasi-magical operations.

spawn-monsters – Controls whether monsters show up at night or not.

generate-structures – Controls whether your world will have temples and villages.

level-seed –  Leave this blank to use a random seed. The seed controls which of the 18,446,744,073,709,551,616 possible worlds are generated. As with level-name, avoid using characters which could interfere with the bash script which installs Minecraft. No spaces or punctuation like quotes, explanation marks, backslashes.

Click OK

Summary

Next you’ll see a summary of the options you picked…

image

Click OK.

Buy

At the purchase blade you confirm that you’re deploying the Azure resources. Note there are no extra charges on top of the Azure resources, just the basic compute and storage charges.

image

Once you click the Purchase button your Minecraft server will start deploying and you’ll see a progress icon on the dashboard. Allow several minute for this to deploy.

image

Connecting to the Minecraft Server

Once deployment is complete you’ll see the resources that were created in the portal..

image

Click on the Public IP address and you’ll see the DNS name you’ll use to connect to from your Minecraft launcher:

image

Start your Minecraft desktop client. Use the regular desktop app, not a pocket edition which won’t connect to regular multiplayer servers like the one you just created. Click Play->Multiplayer and then select Direct Connect or Add Server like this:

image

Once connected you (and only you) should be an operator. You should be able to type commands like /gamemode 1 to switch to Creative mode:

Minecraft 1.11.2 2_11_2017 2_55_43 PM

The full list of operator commands can be found on the Minecraft wiki:  http://minecraft.gamepedia.com/Commands#Summary_of_commands

Troubleshooting and managing
Troubleshooting may involve logging on to the VM directly. For this you need to SSH to the DNS address. If you’re connecting from Windows you’ll need to get an SSH client like putty (see this article for more examples), or better still SSH directly from the Windows subsystem for Linux which is available in Windows 10 Anniversary edition and later. In the example above the SSH command would be:
ssh mcserver211.southcentralus.cloudapp.azure.com -l mcuser

  1. Manually stopping/starting the Minecraft server on the VM
    ssh to the VM
    sudo systemctl stop minecraft-server
    sudo systemctl start minecraft-server

2. If you need to edit any of the Minecraft server files, they are in /srv/minecraft_server

3. Cannot SSH to the VM
Go here: https://github.com/Azure/azure-linux-extensions/tree/master/VMAccess

4. Upgrading Minecraft to the latest server version
Use this script: https://msftstack.wordpress.com/2016/06/25/upgrading-minecraft-on-an-azure-vm/.

Next Steps

There is another Minecraft server in the Azure Marketplace called Multicraft. I’ve not tried it myself yet but Bitnami have good solutions. It’s an advanced hosting platform for Minecraft so worth trying.

If you have any ideas to improve the Azure Marketplace Minecraft Server template, the source files are here: https://github.com/gbowerman/azure-minecraft/tree/master/azure-marketplace/minecraft-server-ubuntu – please take a look and log issues or submit a PR. 

Advertisements
This entry was posted in Cloud, Computers and Internet, Games, Ubuntu and tagged , , , . Bookmark the permalink.

30 Responses to Deploying Minecraft Server on Azure

  1. Pingback: Creating and Operating a Minecraft Server in Microsoft Azure | MSFT Stack

  2. Pingback: Creating a Minecraft server using an Azure Resource Manager template | MSFT Stack

  3. xulture says:

    Thanks!! I just got one going 🙂

    Is there a way to use server console? (via ssh?)

    • sendmarsh says:

      @xulture, yes. If you ssh to the VM and start the server manually. E.g. you can run:
      cd /srv/minecraft_server/
      sudo systemctl stop minecraft-server
      sudo java -Xms1g -Xmx2g -jar ./minecraft_server.1.11.2.jar

      Then your ssh session will show the server console.
      Remember to run sudo systemctl start minecraft-server before you log out if you want the server to keep running.

  4. snugam says:

    We’re a group of friends playing; we’ve moved our server from Realms due to serious lag issues when players are flying with Elytra. Before I’ve setup my own Ubuntu server to host it, but this time I am using this one from the market place.

    Can you tell me what Xmx and Xms values you used for the default config, or tell me where to check/changes these for systemctl minecraft_server

    thank you very much for going t the trouble to build it – was incredibly easy to setup.

  5. theDurpachu says:

    hi i’m having a little problem when i try to put in a password for the VM it says invalid password any reason why?

    • sendmarsh says:

      If you successfully logged on to the VM before, then I can’t think of a reason it would stop working. If you’ve never been able to log in then it’s possible there was some issue typing in your password at deployment time. Either way, you can fix this by viewing the VM in the Azure portal, and selecting the Reset Password option under Support and Troubleshooting.

    • sendmarsh says:

      I realized you’re saying it doesn’t like the password when you’re typing it in in the portal. You should be able to enter any valid Linux username and password for the VM configuration. Some things to keep in mind:
      – Don’t use characters in the password that are bash shell special characters, i.e. avoid using “‘`$\#[]!|;{}()~
      – Make the user name at least 6 characters
      – Have a password length of at least 10 chars. In fact try 12.

  6. Luis says:

    Thanks for this.

    I deployed two servers however I have two issues:
    – I can’t break any block, I can hit the animals but not blocks of any kind.
    – Punching a tree or any block keeping the mouse pressed won’t continue to hit as it normally does.

    Any ideas?

    • sendmarsh says:

      Does it work if you switch to creative mode by typing: /gamemode 1
      If it does, then you have a good Minecraft server install, so the issue might be with your client. If that doesn’t work, then it implies you are not an operator, so something may have gone wrong when you entered your Minecraft user name during VM deployment.

      • Luis says:

        I have deleted both, re-deploying a new instance, but I could run /time set day and it worked so I am an op. Also I had followed your other guide from github and have had that server running for a while and the same computer works fine with that server.

      • Luis says:

        Additional not, I am running 1.11.2 client and the current working server.

      • Luis says:

        Switching to /gamemode 1 and then back to /gamemode 0 fixed it!

        Thanks!

  7. Graham says:

    would you be able to allow us to customize the generation settings for the worlds, like Dungeon count, ore levels etc?

    • sendmarsh says:

      You mean add these settings as Azure template parameters? Do you know if there are configuration files for these settings? If there are, then it should be possible to create a customized template for it.

  8. derek gusoff says:

    Hi, I’m unable to connect to the server. I’m getting a “Connection Refused. No Further Information”. It seems port 25565 is not open. I can see in the NSG there is an inbound rule allowing the port along with the SSH port 22.. I can see the ufw firewall in Ubuntu is disabled. But running a scan via http://www.yougetsignal.com/tools/open-ports/ only shows port 22 as open. I also tried restarting the server as noted in the troubleshooting steps. Any idea what I might have done wrong here?

    • sendmarsh says:

      Hi, my best guess is that the port isn’t open because the Minecraft server isn’t running. Can you check if the VM extension which installs Minecraft ran correctly? One way to do this is to look at the VM instance view. E.g. you could go to resources.azure.com, find your subscription->resource group->virtual machine, click the plus sign by the virtual machine the virtual machine and click on the instance view. This should include the output from the extension near the bottom of the scrreen. Another option would be to ssh to the machine and look in /srv/minecraft_server to see if anything was created. If something went wrong with the extension, cleanest fix would be to delete your resource group (assuming you’re not using if for anything else) – which removes everything – and try deploying Minecraft again. If it fails again, we have a problem and I’d like to see the extension output.

      • derek gusoff says:

        Hi, thanks for the detailed troubleshooting steps. I tried a new resource group and new Minecraft server VM, but seem to have the same issues as the first with connecting via the Minecraft client. I can see that /srv/minecraft_server has the server jar, the properties file, and the other files and directories I would expect there. I’ve uploaded the instance view file to https://derekpics.blob.core.windows.net/files/minecraftInstanceViewJson.txt. Let me know if you’d like to see more.

        I appreciate your help here. I feel like I’m really close.

      • sendmarsh says:

        I tried deploying a new Minecraft server and it has started failing for me. I ssh’d into the VM and looked at /srv/minecraft_server/logs – the server is getting an exception when it starts: [04:19:40] [Server thread/ERROR]: Encountered an unexpected exception
        com.google.gson.JsonParseException: java.io.EOFException: End of input at line 1 column 1 path $
        I looked at the crash file, and it said exception in server tick loop.
        It looks like the new 1.12 server is having trouble reading one of the JSON files.
        I deleted banned-ips.json, banned-players.json, whitelist.json and then ran sudo systemctl restart minecraft-server
        The server then came up correctly.
        I think I know what the problem is. I was creating empty files for those json files if the user doesn’t set anything. It looks like the server crashes if an empty json file exists, but it is ok if there is no file, or if the file contains “[]”. I will fix up script and re-stage it. In the meantime you should be able to get your server working by deleting the same json files and restarting the service as above.
        Sorry you ran into this, I assume everyone is running into it now. Thanks a lot for raising the problem. I’ll let you know when a fixed version is in the marketplace. [ Update: put a temp fix in the Azure quickstart templates version: https://github.com/Azure/azure-quickstart-templates/tree/master/minecraft-on-ubuntu ]
        [ Update 6/18: problem now fixed in Marketplace ]

    • sendmarsh says:

      Update 6/18: A new template has been pushed to production. Just tested and confirmed it works. The problem was Minecraft Server 1.12 crashes trying to read empty JSON files when starting up. The solution was to not create empty JSON files and let the server create its own as needed.
      @derek_gusoff thanks a lot for reporting this. Please give it another try when you get a chance, the Minecraft server in the Marketplace should be working correctly now.

  9. derek gusoff says:

    Hi sendmarsh, deleting those files did the trick, and my server is now up and running! I also learned a few things, which was the whole point fo this exercise.

    Thanks so much for jumping on this and helping me to a resolution. I’ll also try the template again and see if everything is working OK. I’ll report back if I find issues.

  10. Pingback: Cómo crear un servidor Minecraft en Azure – Francisco Martinez

  11. do you have any pointers for adding mods on a server set up with this template (really nice setup, thanks!)

    • sendmarsh says:

      Good question. I don’t have much in the way of pointers for mods. I’d love suggestions on handling mods well for Minecraft deployments on Azure.

  12. Evert says:

    Hi, great job!
    My problem is that when the server is stopped and later restarted, it won’t allow client to connect. Connecting refused error on client side.
    Firewall open in Azure.
    Do you have any clue?
    Thanks
    Evert

    • sendmarsh says:

      @Evert how are you stopping the server, and are you checking it’s stopped? I’m not sure sudo systemctl stop minecraft-server actually stops the process, a kill might be better.
      If you’re sure no process is running, does sudo systemctl start minecraft-server then work?

      • Evert says:

        By “server”I mean the virtual machine, not the Minecraft server( sorry about the confusion). So my problem is; when the VM is first deployed and started I can connect fine and everything works perfectly, but once the Vm has been restarted, connection is refused. The azure firewall settings are not changed.
        Thanks Evert

      • sendmarsh says:

        When did you first deploy the VM? There was a bug earlier, fixed a few months ago caused by the service not being executable. You can fix it on an existing VM with “sudo chmod +x /etc/systemd/system/minecraft-server.service”

      • Evert says:

        Thanks, by manually starting the Minecraft service after restart it works. I wrote a powershell script for that.
        Best regards
        Evert

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s