Running Minecraft on Service Fabric Mesh
Published Aug 06 2019 05:22 PM 2,634 Views
Bronze Contributor
First published on MSDN on Jan 11, 2019
Welcome to the first post of 2019! This post was authored by Suneet Nangia (Microsoft) working with Mark Fussell (Service Fabric team).

As a part of on OpenHack event in London recently, I had a chance to run a Minecraft server on Service Fabric Mesh . In this blog I will go through the aspects of configuring and running Minecraft on Mesh and then showing an upgrade where the state of the game is maintained using a Service Fabric Reliable Disk volume . You will need to buy (or have already) a copy of the Minecraft client in order to play which is available here https://minecraft.net/en-us/download/

Mesh is in public preview and features are still in beta/development stages, nevertheless the example demonstrates the value proposition of Mesh. The Minecraft server is available as a container for both Windows and Linux platforms. We will use the container available for a more recent version of Windows, 1803 on the Docker Hub Openhack repo here openhack/minecraft-server:1.0-nanoserver-1803

In order to run the Minecraft container image, you need to set up the following;

  1. Port 25565 is required to allow clients to connect and play.

  2. Port 25575 is a RCON port required to manage the server remotely.

  3. Running Minecraft server needs EULA to be accepted.

  4. The game server container needs at least 2 cores to run correctly.


Here’s what the overall flow looks like from development, to deployment and then playing.


ARM Template


In Mesh, all application related resources are first class ARM resources of ServiceFabricMesh resource type i.e. they are part of Mesh resource provider including Networks and Storage. The ARM template for the Minecraft app design is shown below.

Here you will see that I have created a ServceFabricMesh/gateways for the ingress ports both opened as TCP. By mounting a Service Fabric Reliable Disk volume to c:\data folder allows, Minecraft container to save the game progress/world to persistent storage. As a resultif the container host VM machine is failed over or the container is restarted (due to an upgrade for example), you do not lose the game data.

The complete ARM template is available here on a GitHub gist which you can download and run in your Azure subscription.


Deploying the Minecraft application


Mesh is currently free and available in US West, US East, and Europe West regions during a public preview period.

You can deploy the ARM Template with the Azure CLI and Mesh CLI . Here are the steps.

  1. az login

  2. az account set --subscription "<subscriptionID>"

  3. az group create --name MinecraftMesh --location westeurope

  4. az mesh deployment create --resource-group MinecraftMesh --template-uri https://gist.githubusercontent.com/suneetnangia/7b0857ed69e89abb6b7fe6d166a83bc8/raw/14697c142ac285b... --parameters "{'location': {'value':'westeurope'}}"

  5. Step 4 above will provide you with a public IP of the Mesh Application. Look for “outputs” in the response JSON. Or use CLI command


“az mesh gateway show --resource-group MinecraftMesh --name MinecraftGateway”

to display the gateway details. You can also go into the Azure portal to see the deployed application with the MinecraftServerSvc service running (see screenshot below)



  1. You can install the Minecraft client from here https://minecraft.net/en-us/download/


When connecting the Minecraft client,

  1. Click Multiplayer and select Direct Connect.

  2. Enter the public IP address of the Mesh application (see screen shot below)




Enjoy crafting on Service Fabric Mesh!

Upgrading the Minecraft application and maintaining game state


Let’s now upgrade the MinecraftServerSvc service by updating the value for the memory allocated, perform an upgrade which will restart the container, and then reattached the client to see how the game state has been preserved.

  1. First play Minecraft and change something in the game.

  2. Download the ARM template to your local machine and open this in a text editor. Save the file as “MinecraftOnMesh.json” and update the memoryInGB from the value “2” to “2.5” like this.


"resources": {

"requests": {

"cpu": "2",

"memoryInGB": "2"

}

  1. Now update the current Mesh application deployment using this local ARM file (provide a suitable path) using the following CLI command


az mesh deployment create --resource-group MinecraftMesh --template-file ./MinecraftOnMesh.json –parameters "{'location': {'value':'westeurope'}}"

You can watch the upgrade either with the “az mesh deployment show” command or by watching the activity in the Azure portal. The screen shots below show the upgrade activities and the final completed deployment in the portal































Now reconnect the Minecraft client to the Minecraft server (it will have the same IP address) and see that your game state is the same despite the service being upgraded to have more memory.

For more samples and tutorials on Service Fabric Mesh go to http://aka.ms/sfmesh

Enjoy persistent crafting on Service Fabric Mesh!
Version history
Last update:
‎Aug 06 2019 05:22 PM
Updated by: