MCRCON with Azure Notebooks + ACI

Prepare Minecraft server on ACI (Azure Container Instances).

$ az group create -l southeastasia -g mycraft
$ az container create --image itzg/minecraft-server -g mycraft -n mycraft --ip-address Public --ports 25565 25575 --cpu 2 --memory 7 -e EULA=TRUE ENABLE_RCON=true RCON_PASSWORD=testing

You’ll see the public IP address just after starting the container.

Install MCRCON on Azure Notebooks.

!pip install mcrcon
from mcrcon import MCRcon
with MCRcon("40.65.169.146", "testing", 25575) as mcr:
    print(mcr.command("/give @p diamond_sword"))

Enjoy!