This post explains how to rapidly configure and deploy a customized Minecraft server using an Azure template.
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: https://msftstack.wordpress.com/2017/02/11/deploying-minecraft-server-on-azure/.
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 server.properties 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
- An Azure account. If you don’t have one you can sign up for a free trial here: http://azure.microsoft.com/en-us/pricing/free-trial/
- A Minecraft account. See https://account.mojang.com/register?agent=minecraft – you’ll need your Minecraft user name (not your email address) to deploy the template.
- Minecraft launcher to connect to your server: https://minecraft.net/download
Deploy the Minecraft template
Go to the Minecraft on Ubuntu community template: https://github.com/Azure/azure-quickstart-templates/tree/master/minecraft-on-ubuntu
(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.
- 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 ‘fredsworld.southeastasia.cloudapp.azure.com’ you would need to type in fredsworld here. The string has to be unique in your region, and no special characters.
- 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: http://minecraft.gamepedia.com/Server.properties
- 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.
Now we get to the Minecraft specific parameters….
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.
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 preview builds. In this example the SSH command would be: ssh msftstack.eastasia.cloudapp.azure.com -l mineuser
- 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: https://github.com/Azure/azure-linux-extensions/tree/master/VMAccess
5. Upgrading Minecraft to the latest server version
Use this script: https://msftstack.wordpress.com/2016/06/25/upgrading-minecraft-on-an-azure-vm/.
Where to go next
The Azure Resource Manager templates are available in github (https://github.com/Azure/azure-quickstart-templates), 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.