Here I explain how to run Minecraft Java server on Azure Virtual Machine.
You need virtual server for running Java Minecraft server. This virtual server can be any Linux or Windows operating system which can run lateste Java version. For example:
Minecraft Java server downloads can be found https://www.minecraft.net/en-us/download/server
Example of logging to server and install Minecraft Java server:
# Login to linux server with SSH
ssh -i your-vm-ssh-private-key.pem azureuser@your.server.ip.address
# Update Ubuntu OS First
sudo apt update -y && sudo apt upgrade -y
# Install latest Java
sudo apt install openjdk-21-jdk -y
# Create new folder for Minecraft server
mkdir minecraft-1.2.1
# Create symbolic link for Minecraft
ln -s minecraft-1.2.1 minecraft
# Download Minecrat Server
cd minecraft
wget https://piston-data.mojang.com/v1/objects/59353fb40c36d304f2035d51e7d6e6baa98dc05c/server.jar
# Start Minecraft server first time
java -Xmx1024M -Xms1024M -jar server.jar nogui
# Setup eula.txt
vi eula.txt
eula=true
# Setup server properties
vi server.properties
difficulty=easy
gamemode=survival
hardcore=false
max-players=10
server-port=25565
# Start Minecraft server as background process
java -Xmx2048M -Xms1024M -jar server.jar nogui &
Above you can see some examples of "server.properties" file configurations. You can modify it as you want. For example, if you want to start server in "harcode" mode, you need to set:
hardcore=true
You need to restart Java server to take new configurations in use.
You can now launch your Minecraft on your gaming pc or laptop and start multiplayer session.
Add new server and configure name for the server and server address. Use your Azure virtual machine ip addresses and server-port of Minecraft configured earlierd.
For example:
Server address: 123.22.34.56:25565
Now server is up and running, but also costs are running all the time. You might want to stop spending money when you are not playing.
So it is time to automate server for launching Minecraft Java server up every time serves is powered on in Azure portal.
We already configured virtual machine automatic shutdown when we created the server and that can be adjusted in the virtual machine configurations as you wish.
Here is example, how to automate Minecraft server automatic startup in Ubuntu Linux:
# Create new linux service
sudo vi /etc/systemd/system/minecraft.service
# Configure service
[Unit]
Description=Minecraft Service
[Service]
User=azureuser
Group=azureuser
WorkingDirectory=/home/azureuser/minecraft/
ExecStart=/usr/bin/java -Xmx2048M -Xms2048M -jar /home/azureuser/minecraft/server.jar nogui
RestartSec=10
Restart=always
[Install]
WantedBy=multi-user.target
# Enable service
sudo systemctl enable minecraft.service
# Check services status, stop or start
sudo service minecraft status
sudo service minecraft stop
sudo service minecraft start
Now every time you shutdown the virtual machine that new "minecraft service" shutdown the Java process down first cleanly and then the vm shutdoen itselft. And every time you start the virtual machine from Azure portal, it starts up "minecraft service" automatically. And you are ready to play!
When you want to update new version of Minecraft, follow this process:
It is very cheap to run virtual machines and services on Azure when you automate the shutdown and startup process.
You can keep server up and running only that time you are using the service and avoid spending money of idling resources.
In Azure cloud services costs are per seconds of running capacity and mostly for example playing Minecraft you pay only couple of Euros per month.
Next time you want to play Minecraft, you go to Azure portal, just press virtual machine start button and you are ready to go!