Creating a Minecraft server using an Azure Resource Manager template

This post explains how to rapidly configure and deploy a customized Minecraft server using an Azure template.

Update 2/11/2017:
There is now a Minecraft Solution template in the Azure Marketplace, which provides all the customization options described below. You can read about it here:

The article below describes the Minecraft Server Azure template available in Azure Quickstart Templates. Read on if that’s what you’re looking for.

Why use a template?
In a previous post I explained how (and why) to create a Minecraft server running on an Ubuntu virtual machine in the Azure cloud using the Azure Minecraft Server marketplace VM image. It works fine, though you have to do things like log on to the machine to configure Minecraft. Wouldn’t it be handy if you could also:

  • Configure your Minecraft server properties without having to SSH to the VM and edit the file.
  • Make yourself an operator without having to look up your Minecraft user UUID, SSH to the VM and edit the ops.json file.

In other words, although using an Azure Marketplace image for Minecraft saves you from having to set up a machine, install Java, install a Minecraft server, etc. it doesn’t save you from having to manually configure the server. This is where using an Azure Resource Manager template can help.

Wait, what’s a template?
An Azure template provides a way to provision applications by describing a set of cloud resources and how they are related. With a template you can do things like create cloud storage account(s), virtual network(s), virtual machine(s), specify what should run on the machine(s) in the form of a script or pre-packaged extensions and more. When someone deploys this template they don’t need to know about or spend time configuring the underlying cloud infrastructure, they just provide whatever information the template asks for. Various community templates have been written which allow you to deploy a range of applications like MySQL, Docker Swarm, Octopus Deploy etc.

In the case of the Minecraft template, when you deploy, it asks you for your Minecraft user name and automatically makes you a Minecraft operator. You can optionally provide Minecraft server configuration parameters like game mode, difficulty, level name etc., which save you from having to log on to the machine and set them up yourself.

What you need to get started

Deploy the Minecraft template
Go to the Minecraft on Ubuntu community template:

(BTW if you’re looking for a template to deploy Minecraft on Windows, try this one: Minecraft – Single Server.)

Click the big Deploy to Azure button.

As long as you have an Azure account, this will then take you to the Azure portal Custom deployment screen, which looks like this:


Let’s go through the parameters you need to fill in here, and which ones are important…

  • Template : You don’t need to look at this unless you want to. It’s the template you’re about to deploy, written in JSON. It’s recommended not to change this, though an advanced user could do things like edit the machine size here for example.
  • Parameters:
    • MINECRAFTUSER: It’s important  to put your existing Minecraft user name here, not your email address, or anything else. If you get this wrong you won’t be an operator of the server when it is created.
    • ADMINUSERNAME: This will be your Linux username if you ever have to log on to the virtual machine (the plan is that you won’t have to). Put something like mineuser for example.
    • ADMINPASSWORD: A password for the new Linux user that gets created. Something you’ll remember, secure enough to not be easily hacked.
    • DNSNAMEFORPUBLICIP: This will become the first part of the URL for the new server that gets created. E.g. if the full domain is going to be ‘’ you would need to type in fredsworld here. The string has to be unique in your region, and no special characters.
    • Now we get to the Minecraft specific parameters….

    • MINECRAFTSERVERVERSION: Update 2/11/17: This parameter was removed. The Minecraft Server install script always gets the latest version now.
    • DIFFICULTY: The default Difficulty of 1 means peaceful mode. Check here for what values you can use for this and the next few parameters:
    • LEVEL-NAME: Whatever you want your new Minecraft world to be called. It is very important that you 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.
    • WHITE-LIST: Set this to true to make this invite-only – 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 limitless array of quasi-magical operations for your server.
    • SPAWN-MONSTERS: Controls whether monsters show up at night or not.
    • GENERATE-STRUCTURES: Controls whether your world will have temples and villages.
    • LEVEL-SEED: A random seed will be used unless you put a value in here. This 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 like spaces, quotes, explanation marks, backslashes.
    • Click OK on the parameters panel so you can enter the rest of the values.

  • Resource Group: All the cloud resources that the template creates, like storage account, virtual network, virtual machine will be in a logical grouping called a resource group. This is useful because when you’re ready to delete the server, just delete the Resrouce Group to remove everything. I recommend creating a new group here. Give it any name (you haven’t used before) like minecraftserver.
  • Resource Group Location: Might as well pick the same location you used for LOCATION above.
  • Legal Terms: Click on this. In theory you read it (like anyone does) and then click Buy (the template doesn’t have a cost, you just get billed for the Azure resources you use). You have to click Buy to get past this screen.

At this point you’ve filled in a bunch of values like this:


Now click Create.

You can check the progress of the deployment using the Notifications tab. After a few minutes you should see a Deployment Successful notification like this:


After a successful deployment you can find your virtual machine by selecting Browse All->Virtual machines, or by clicking on the resource group that gets created and then selecting the virtual machine. Click on the virtual machine:


And then click on the Public IP Address:


Make a note of the DNS name. That’s the “Server Address” you’ll add when you go into Multiplayer mode in your Minecraft client to add or connect to a server.

Connect to the server

Fire up 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:


Then you’re done. Connect to the server, and then once you’re in, confirm you’re an operator by typing a privileged command like /time set 0 which sets the time to midday.

Minecraft 1.8.8 9_5_2015 3_22_26 PM

The full list of operator commands can be found on the Minecraft wiki: 

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 preview builds. In this example the SSH command would be: ssh -l mineuser

  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. Checking the Azure VM extension logs.
Look at the logs that show the status of the script that installed the Minecraft server here:

4. Cannot SSH to the VM
Go here:

5. Upgrading Minecraft to the latest server version
Use this script:

Where to go next 

The Azure Resource Manager templates are available in github (, so you could fork and make your own versions, for example, create a Minecraft server template with a different (or variable) machine size, create a server on a different OS, set up network security rules, deploy a modded server etc.

The next thing on my to do list is to write a template for a Minecraft server running on Windows, so you have a choice of deploying a server on Windows or Linux. More suggestions always welcome.

This entry was posted in Cloud, Games, Linux, Ubuntu and tagged , , . Bookmark the permalink.

53 Responses to Creating a Minecraft server using an Azure Resource Manager template

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

  2. Pingback: Azure templates for ComputerCraftEdu and Scriptcraft servers | MSFT Stack

  3. yodasoja says:

    This is great! I’ve been trying to use this, but I’m trying to update it to change the minecraft version from 1.8 to the newly released 1.9. How can I modify the files after this setup to do that?
    (just replacing the .jar doesn’t seem to work)

    • sendmarsh says:

      Great question. I’d not been paying attention to 1.9. I’ll try installing and seeing what’s changed, and hope to update the template in a few days. Also Ubuntu 16.04 LTS is out next month, and will definitely update the template for that too.

      • yodasoja says:

        Thanks for the reply! 16.04 would be nice for this setup to have.
        I just went into the minecraft-server.service, and changed the it to use the newer .jar file and it worked. Though, it seems to crash when I had 4 people on who were in different parts of the map. Probably just a RAM shortage or something like that…

      • sendmarsh says:

        Thanks for testing that. Looks like I’ll just be able to update it without change then. Did you try 1.8 with 4 players and the same machine size? I’m wondering if I should wait if you think it’s less stable…

      • yodasoja says:

        This is my first time trying this template, so I didn’t try it on 1.8. I used your earlier tutorial ( to setup my 1.8 machine and it worked flawlessly with 4 people (never crashed) unlike any other setup I’ve done. Even my home-hosted 1.8 used to crash when I gave it 4+GB of RAM.

  4. EJ says:

    Hey sendmarch, thanks a lot for this great walkthrough. As many dads I suffered this weekend from the breaking change in the minecraft server/client, so following this I managed to get a 1.9 server stamped up easily! I just downloaded the ARM template, changed every reference to 1.9, and (after a failed attempt) found out the shell script had some references as well, and is referenced in the json to be downloaded from GitHub. So I changed the shell script, uploaded it to temp storage account, changed the json to reference ‘my’ 1.9 version of the script and used the powershell tools to deploy the server.

    Thanks a lot!

    • sendmarsh says:

      Thanks EJ. Glad you were able to use this info and build on it. Based on your and Yoda’s experience I’ll go ahead and update to 1.9. Maybe at the weekend..

    • Matthias P says:

      Hi EJ,
      great, that it works. Did you take the 1.9 Vanilla or a Bukkit/Spigot version ? I tried to update as well, but it only works with a 1.9 Vanilla version provided by the official minecraft website.
      If you dont mind and if you are using a Bukkit or Spigot version – could you provide me a how-to for windows users ? 😉

      Thanks in advance

      • EJ says:

        Hi Matthias, I just downloaded the official minecraft server version. What would be the benefit for using Bukkit/Spigot?

      • Matthias P says:

        Hi EJ,
        the benefit of Spigot is, that you can run plugin´s for your server, like more then one world, portals between worlds, permissions and so on.
        I played around with this server and right now, i have a network with 7 connected minecraft servers up and running. Even the new 1.9.2 and 1.8.x versions at the same time.

  5. sendmarsh says:

    The Azure Resource Manager template has now been updated to take the Minecraft version as a parameter argument. You can choose 1.8 or 1.9. Thanks @digitalbanana for the pull request. Will update the blog post…

  6. malckier says:

    I tried out the defaults and got a lot of “Can’t keep up!” messages and java exceptions. Kind of cool to set it up this templated way, but I think you’d have to use a tool like bukkit to help speed up the game by managing the resources better.

  7. stumpykilo says:

    I keep getting a “Connection refused” error when I try joining the server. The inbound security rules were setup by default and I can SSN to it just fine. Any suggestions?

    • sendmarsh says:

      If you can SSH to the machine OK, can you follow the troubleshooting steps 1-3 in this article? Are there files under /srv/minecraft_server? Is the Minecraft configuration file there and populated correctly? Can you find the extension logs under /var/log/azure/Microsoft.OSTCExtensions.CustomScriptForLinux? Do they indicate an error message?

      • stumpykilo says:

        Thanks sendmarsh! Yes, I’ve done all those steps and the files are all there and the configuration file is there populated correctly. I see the CustomScriptForLinux folder with under that but do not see any log files there.

      • sendmarsh says:

        If you didn’t see any extension log files were you looking as sudo?
        If you were able to run the sudo systemctl commands without error, that should mean the Minecraft server is just fine.
        If so, do you get the same connection error if you put the ip address in your Minecraft client instead of the DNS name, to rule out anything wrong with the DNS name?

    • stumpykilo says:

      Ok, so this is embarrassing…I changed the Azure size to A0 (the template had something bigger) and THAT is too small to run the Java runtime. So I switched to A1 and everything is good. A0 only has 0.25 GB RAM.

  8. pade says:

    Nice work.
    One issue though is that the Minecraft service is running with the root credentials. It would have been better to have the service running with the minecraft.minecraft credentials

    Also the version of the Minecraft would better be able to specify manually since this template shouldn’t have to be updated each time there’s a new Minecraft server version

    Me personally have some special needs as I’m running more than one Minecraft server services on each Azure server. I do this by adding a second Minecraft folder and increasing the listening port number, i.e 25565 to 25566 in the file. But since this requires a dns srv-record to be created, it will not be a common request from everybody though

    • sendmarsh says:

      Thanks for taking a look and for the detailed feedback. I agree with your suggestion on root credentials. Please consider a pull request on github to improve the script (I’m a little wary of doing that myself since I’ve created Ubuntu systemctl services running as other users and don’t know if there are any side-effects in terms of file permissions when the service interacts with other files).

  9. pade says:

    totalMem=$(free -m | awk ‘/Mem:/ { print $3 }’)
    shall be
    totalMem=$(free -m | awk ‘/Mem:/ { print $2 }’)

    $3 is used memory, and $2 is total memory

  10. I have tried this template and whatever I try I get the error message:

    The template deployment ‘Microsoft.Template’ is not valid according to the validation procedure. The tracking id is ’59d24981-1d1e-49ed-963b-3eebf58b8688′. See inner errors for details. Please see for usage details.

  11. figured it out, I assumed DNS name was for assigning my own domain and pointing it to the vm but I guess its just for azure to create a domain as once I just had a single word the templated worked

    • sendmarsh says:

      Hey, thanks for the follow-up. I’m glad you figured it out. I do a quick update of the article and see if I can make that section clearer.

  12. Charlie says:

    Is there a way to automatically run the sudo systemctl stop minecraft-server command when the vm is re-started? And (on a related note) is there a quick and easy way to schedule the vm to start/stop to some schedule? (There are plenty of guides on automation, but they get complicated, and often outdated, pretty quickly!)

  13. Hans-Ueli says:

    i get the server running fine and can connect, it s all good. HOWEVER, when i restart the server i cannot connect anymore Java.ConnectExeption:ConnectionRefused

    • sendmarsh says:

      Can you go through the troubleshooting steps in the article? For example can you ssh to the machine, check the service is running etc.?

    • sendmarsh says:

      There is a fix for this problem. SSH to the machine and run:
      sudo chmod +x /etc/systemd/system/minecraft-server.service
      I’ve fixed the templates so this problem shouldn’t happen any more.

  14. featherclaw says:

    I cannot seem to create the server!
    I followed your instuctions over and over again, for the Ubuntu as well as for the windows Server but nothing seems to work. As soon as i hit the create button after following all the steps it just shows me an exclamation mark and if i then go trough the steps again and tiping the admin password back in it says “Please fix the errors on this page before continuing”. Then it also shows an exclamation mark next to the Legal Terms, but when i re-purchase it, nothing chances…

    please help!!!

    • featherclaw says:

      I just rememberd that I have still a Wondows 7 PC, is that a problem? If yes, i hate microsoft for that

      • sendmarsh says:

        Hi, OS version shouldn’t make any difference as you’re deploying the template in a browser. This works fine from Linux, Mac OS, Windows. (Though I would advise looking into upgrading your OS before the free upgrade runs out on July 29).
        It’s hard to tell what’s wrong from your description. Two suggestions: 1. Can you try deploying some other template, like – that way you can rule out whether it’s an issue with the Minecraft template or with the way you’re using the Azure portal.
        Another suggestion is if you could share a screenshot of the problem somewhere. Might help figure out what’s going on.

  15. Gabriel Moncau says:

    Hi. How do i upload my own world to the server? And how do i run experimental 1.10 Snapshots? Thanks!

    • sendmarsh says:

      Hi, here’s how I’ve uploaded my own world to the server – I’ve only tried this Linux -> Linux…
      1. Stop the Minecraft server on the source machine.
      2. On the source: Copy the entire world directory. E.g. for Linux: tar cvfz myworld.
      3. Do a binary transfer of the file to the target machine. I used winscp, and made sure to set the transfer mode to binary.
      4. Shutdown the server on the target machine. sudo systemctl stop minecraft-server
      5. cd to the /srv/minecraft_server directy and unzip the world folder. If it has the same name as an existing one delete the existing one first. E.g.
      gunzip myworld.tgz
      tar xvf myworld.tar
      6. Change any config files to match the source – you could just copy the config files from the source.
      7. Start the minecraft server.. sudo systemctl start Minecraft-server.
      Most of this could be scripted/automated.
      Regarding your question about 1.10 snapshots. Do you have a link to where they can be downloaded from? I can add them to the template..

  16. Leckster says:

    Hi. Just deployed your template successfully and want to start by saying that this is an amazing project. Thanks!

    Second, I’m curious if anyone else has run into this issue I’m having with whitelisted accounts. When I connect with my account which was added as an operation upon creation I have no issues, but my brother who connects with his account which i added to the whitelist is having extreme lag to the point of being unplayable. For example he can’t walk through open doors, place blocks, or punch blocks. (I can see the animations for these from my account, but nothing ever happens). Any thought what this might be? Is it because he’s an operator? I’m tested his account from my house so I know it’s not a location/latency issue. Is it because of the whitelist?

    • sendmarsh says:

      Thanks Leckster! I’ve not heard of a problem with whitelisted account performance. One test which should prove or disprove it would be to remove your brother’s account from the whitelist file. It doesn’t need to be there since he’s an operator anyway. You could either edit the whitelist file or use the /whitelist remove command. After that your accounts will be equivalent.
      If you’ve ruled out network connection, or latency due to distance from the data center, another thing to consider might be virtual machine size (though if you still see the lag with only one player connected I’d be surprised if it was that). I’ve found Standard_D2_v2 is a good size for more than one player at a time, though of course it’s pricier than a single core VM like Standard_A1 or Standard_D1.

      • Leckster says:

        Thanks! I resolved my issue, thought I don’t know why, I added my brother’s account as an operator and then things started working just fine for him (there was a typeo in my original post, he was *not* an operator previously, but was only whitelisted). I didn’t need to remove him from the whitelist or anything else, just made him an operator. Maybe a bug with 1.10 (I deployed directly to 1.10 and have no idea if I would have had this issue in 1.9).

      • sendmarsh says:

        Yeah maybe.. anyhow, glad to here it’s working now.

  17. Pingback: How to convert an Azure virtual machine to a VM Scale Set | MSFT Stack

  18. Pingback: Upgrading Minecraft on an Azure VM | MSFT Stack

  19. Stephen says:

    Hi there. Thanks for this. Made my kids day :). One problem. I used our Mojang login instead of the actual Minecraft username and so we don’t have Operator status. Is there a way to update this manually? Or do I need to start from scratch and redeploy?

  20. Johannes says:

    Brilliant, an easy way to get stuff up’n’running, however I get stuck at one issue. Azure isn’t able to run the newuserscript part of the template. It just keeps ending up in status “Conflict” and with the error message “Enable failed: failed to execute command: command terminated with exit status=1” which doesn’t say much sadly. That way logging in via SSH is out of the question since there are no credentials to log in with afaik. 😦 Am I doing something terribly wrong or is there some bug in either Azure or the template?

    • sendmarsh says:

      Thanks for reporting this. I produced your problem and tracked it down to an invalid “systemctl enable minecraft-server” call in the script. This is now fixed. Please try again.
      BTW you can still SSH into the VM you created, also it should have a valid minecraft server running on it. So if you don’t want to redeploy the template you don’t have to..

  21. johnnyo5 says:

    The minecraft service isn’t started automatically when the VM is started. On every startup or restart, I need to ssh and manually start minecraft with the command:

    sudo systemctl start minecraft-server

    What is the best way to have this command run automatically on startup? I tried the techniques described here: (alternatives #1 and #2) but with no success.

    Thanks in advance!

    • sendmarsh says:

      Thanks for pointing this out, and for trying a solution – if you figure it out let me know, or submit a pull request. I will look into it as well.

    • sendmarsh says:

      Hi, I think I found a solution. I tried logging into the VM and running:
      sudo chmod +x /etc/systemd/system/minecraft-server.service
      Then rebooted and the minecraft-server service was up.
      I’ve started adding a chmod command to the existing templates. Please give it a try and let me know if it works for you.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s