Azure API Management + Azure Service Bus + Minecraft

Ok three things I bet you never thought you would hear together, Azure API Management, Azure Service Bus and Minecraft. Ill give you a minute to get over the WTF which im sure is going through your head about now but let’s see how we can use Microsoft Azure to do some cool stuff in Minecraft.

I know a little bit about Minecraft but compared to AJ (my 9 year old son who is an expert) I know very little. The other day he wanted some help on Minecraft and I saw the below picture.




I was curious and he said “Oh im trying to build a door that you can only get in if you know the password but i need some help with the code”. I was pretty impressed at the way he had been playing with a mod for minecraft called ComputerCraft which lets you add various computer shapes to your world and then do cool stuff with them by connecting the parts and running code in them. When we were working on the sample I discovered that there was an http object available and this got me wondering what we might be able to do. I suggested to AJ that rather than just build a password which is inline and “easy to hack” why dont we pretend its a small office for a real company and use their proper security system to check if the characters are allowed access.

You can also connect to a minecraft server and play with friends, if you would like to learn more about minecraft and minecraft server hosting, you can learn more by visiting websites such as Minecraft is a great game to play on your own and my little boy loves it!!! Playing with other players though is sooo much more fun!

The architecture we would try to build looks like the below diagram.


The key thing I guess from a Minecraft perspective is that if you can call a REST API then you can open up a lot of possibilities for external extensions to the game where you can put your complex code out on the web and just hook into it. What was pretty cool about this particular scenario is it took < 1 day to do the scenario. That really shows the power and speed of delivery that Azure offers you for these hybrid integration and API scenarios but from an interoperability perspective if a 9 year old can call it from Minecraft then it should be call able by most people. Im not sure how relevant the scenario above is in the real world, but maybe as Minecraft evolves in the future it might become relevant that organisations build stuff in public Minecraft worlds and allow the public to come into their buildings. I know there is a project attempting to build the British Museum in Minecraft so imagine if in the Minecraft British Museum you might want to build rooms that are for staff only so perhaps you could add a protected door like this so only people who authenticate with their credentials can access these private rooms. We all know integration is changing so fast these days so who is to say something like this might not be a relevant integration use case at some point in the future.

Walk Through

Rather than a long winded walk through I have created a video which will walk you through this scenario.



Code Sample

The code we used in Minecraft is shown below.

local url = "http://[add name][add key]"

local openTime = 20

local side = "left"

	term.setCursorPos(1, 1)

print("Please supply username")

	local userName = read("*")

	print("Please supply password")

	local password = read("*")

	local httpRequest = "{ \"Username\":\"" .. userName .. "\", \"Password\":\"" .. password .. "\" }"

	local headers = {
		  	["User-Agent"] = "A custom user-agent!", -- Overrides the default User-Agent.
			["Host"] = "Minecraft-Computer", -- A non-standard custom header field.
			["Content-Type"] = "application/json"

	print("Checking access")
	local httpResponse =, httpRequest, headers)
	if httpResponse then
		local httpResponseCode = httpResponse.getResponseCode()
		print("HTTP Response Code: " .. httpResponseCode)
		local responseJson = httpResponse.readLine()
		print("JSON Response: " .. responseJson)

		local isAllowed = string.match(responseJson, "true")
		if isAllowed == nil then
			print("ACCESS DENIED - Sorry you cant come in")
			term.setCursorPos(1, 1)
			print("ACCESS GRANTED - Welcome")
			rs.setOutput(side, true)
			rs.setOutput(side, false)		
		--No Http Response
		print("Nil was returned from api call")







Thanks for checking out my article.  If you liked it or found it useful that's really great.  Please feel free to say hi if you bump into me at any networking events and any likes, shares or feedback on the article are really appreciated.  If you really loved it you are also welcome to buy me a coffee using the button below.

All the best



Buy Me A Coffee

You May Also Like

About the Author: michaelstephensonuk