From Office 365 to Azure to Minecraft, connected with Flow
/"John, what's this headline."
This is just a love serenade to Microsoft's many engineers and teams. Thank you, for making these products that makes these things look easy.
Thank you for showing the world what One Microsoft might look like when everything works together.
Plan
- Minecraft Windows 10 edition in the latest 1.2 (better together update) included web sockets previously only in the Minecraft Education version. Web Sockets lets you connect to a Minecraft game, and remotely execute commands.
- Minecraft Code Connection is an external application that hosts a friendly REST API and translates JSON to web socket. Previously this was only for Minecraft Education Edition. An update in early October allows this to work with Minecraft Windows 10.
https://makecode.com/blog/minecraft/10-18-2017 - Microsoft Data Gateway allows Flow, PowerApps, PowerBI to talk to on-premises environments. It also recently gained the ability to execute custom connections. It is essentially, an enterprise data gateway / reverse proxy that connects your local environment to an Azure Service Bus. The ability to call your custom local REST endpoint was released in September.
https://flow.microsoft.com/en-us/blog/q3-2017-update/ - Cloud based services like Flow/LogicApps, PowerApps, and PowerBI can talk to this connection online, via the magic of Azure Service Bus.
- And because I'm a SharePoint MVP - we are triggering this Flow from SharePoint Online. Because the world needs this.
Setting up Minecraft & Code Connection
https://www.microsoft.com/en-au/store/p/minecraft-for-windows-10/9nblggh2jhxj?rtc=1
Buy or download Minecraft for Windows 10
https://education.minecraft.net/get-started/download/
Download Minecraft Code Connection
https://education.minecraft.net/support/knowledge-base/code-connection-api-documentation/
The API for the JSON messages to send to Code Connection is here.
Code Connection uses Minecraft commands - the option is called "activate cheats" - do this in a creative world.
Code Connection is a separate executable. Run it outside of Minecraft - it'll ask you to enter the command into Minecraft
Use Postman to test your localhost:8080 and send a REST request. You'll see your agent bot move.
Congrats - you now have a REST endpoint that can send game commands to your Minecraft game.
Setting up Flow Data Gateway
https://flow.microsoft.com/en-us/documentation/gateway-reference/
The data gateway also calls your local REST endpoints via a custom connector. This was a feature that was silently released in the deluge of news from MSIgnite. I need to thank @pratapladhani (PowerApps PM) for sending me the link of the announce. It is REALLY obscure.
Congrats - this is your reverse proxy.
Setting up custom connection via this Swagger File I've prepared for you
https://github.com/johnnliu/flow/blob/master/mc-cc.swagger.json
Grab this swagger.json and add a custom connection to Flow
Note the host is localhost:8080
Tick: Connect via on-premise data gateway
Note the custom connection swagger file points to localhost:8080 - this will work if your data gateway is on the same machine as the Code Connection exe. Otherwise, you should use the LAN IP Address of the Code Connection server.
Add a connection, and select On-Premises data gateway
Note the connection type is "On-premises"
Write my Flow
These wonderful methods with dropdowns are defined in Swagger file. It's hard work. Contributions welcome!
Trigger it from Office 365 / SharePoint
Hi bot agent
Code-Less
I want you to understand, all these are done, without me writing a single line of C# or JavaScript.
Cost?
Office 365 E3+ license allows you to have:
- 2000 Flow runs per user
- 1 Custom Connection
- On-Premises data gateway allowed
https://australia.flow.microsoft.com/en-us/pricing/
So there's no extra cost for an Office 365 customer E3+
Summary Key Points
- Minecraft Win10 has websockets
- Code Connection does JSON to websocket
- Data Gateway is amazing, also calls your local REST endpoints
- Microsoft Flow just unlocks it to the rest of the world, if you like, LogicApps will work just as well.
- You can have a PowerApp calling the function via the Custom Connection, without Flow.
- Extremely code-less
Where do we go next?
Well, when I detect an Active Directory User deletion via webhook - I'm going to teleport this Zombie Villager into lava.
Update: I can't see a use case for this
So, some people have commented to me directly - John this is very cute, but there's no business use case for this.
Let me explain the head-fake
Flow can reach into your organization and call any of your REST endpoints with no code
Microsoft Flow blog posted https://flow.microsoft.com/en-us/blog/on-premise-apis/ explaining how you can build your own on-premises API service and call it from Flow via the data gateway. I was bothering them with explanations for the data gateway and I think they were ready to publish anyway, they told me they'll share it in a few days.
I beat them slightly to publish since I worked out how to do the Minecraft bit.
I also think they need more imagination. Minecraft is a hundred times better example and I didn't even have to write a REST service ;-)
<3