Upgrading Minecraft on an Azure VM

When you deploy an Azure Minecraft VM using the Azure Resource Manager template it should be running the latest Minecraft server version, but the Mojang folks update the server fairly often, and before you know it your Minecraft launcher is complaining that the server is no longer on the latest version. If you deploy the Azure Marketplace Minecraft image rather than the ARM template, the server is more likely to be out of date. Here’s how you can upgrade the Minecraft server on the Azure VM to the latest version.

The basic steps are:

  • ssh to the VM.
  • Download the latest Minecraft server JAR file.
  • Update the minecraft-server systemctl service to point to the new JAR file.
  • Restart the minecraft-server service.

For convenience here’s a script that performs all those steps automatically. I’ll paste it below, though go here for the latest version: https://github.com/gbowerman/azure-minecraft/blob/master/scripts/mineserverupgrade.sh.

To upgrade a Minecraft server on Azure (as long as it was originally deployed using the ARM template or Marketplace image), copy the script to the virtual machine and run it using sudo. Since it’s a fairly short script a simple way to put it on the VM might be to just start vi (or nano or whatever) and paste the script into the editor and save it. Then remember to run chmod +x on the file to make it executable, and run it as root. E.g. like this (if you’re upgrading to Minecraft server version 1.10.2):

sudo bash
./mineservererupgrade.sh 1.10.2

Here’s the listing:

# Minecraft server upgrade script for Azure
# $1 = new version (e.g. 1.10.2)

# check for a command line argument
if [[ ! $# -eq 1 ]] ; then
    echo The Minecraft server version needs to be passed as a command line argument, e.g. sudo $0 1.10.2
    exit 1

# server values

# adjust memory usage depending on VM size
totalMem=$(free -m | awk '/Mem:/ { print $2 }')
if [ $totalMem -lt 1024 ]; then

cd $minecraft_server_path

# download the server jar
while ! echo y | wget $SERVER_JAR_URL; do
    sleep 10
    wget $SERVER_JAR_URL

# stop the service
systemctl stop minecraft-server

# move the old service file
mv /etc/systemd/system/minecraft-server.service /tmp/minecraft-server.service.old

# recreate the service
touch /etc/systemd/system/minecraft-server.service
printf '[Unit]\nDescription=Minecraft Service\nAfter=rc-local.service\n' >> /etc/systemd/system/minecraft-server.service
printf '[Service]\nWorkingDirectory=%s\n' $minecraft_server_path >> /etc/systemd/system/minecraft-server.service
printf 'ExecStart=/usr/bin/java -Xms%s -Xmx%s -jar %s/%s nogui\n' $memoryAlloc $memoryAlloc $minecraft_server_path $server_jar >> /etc/systemd/system/minecraft-server.service
printf 'ExecReload=/bin/kill -HUP $MAINPID\nKillMode=process\nRestart=on-failure\n' >> /etc/systemd/system/minecraft-server.service
printf '[Install]\nWantedBy=multi-user.target\nAlias=minecraft-server.service' >> /etc/systemd/system/minecraft-server.service

# restart the service
systemctl start minecraft-server

# closing message
echo Upgrade completed. If any problems, you can revert to the previous version by running\:
echo sudo systemctl stop minecraft-server
echo sudo cp /tmp/minecraft-server.service.old /etc/systemd/system/minecraft-server.service
systemctl daemon-reload
echo sudo systemctl start minecraft-server

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

3 Responses to Upgrading Minecraft on an Azure VM

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

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

  3. Pingback: Deploying Minecraft Server on Azure | MSFT Stack

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