Hello !!!
In this article we are going to learn how can we host our unity3d games on Microsoft Azure Web-Apps via Unity WebGL export.
I have taken this
Unity Sample Game from unity asset store for the sake of this. You can use your own game or anything you wish. You're going to need the following three things to get this done.
Step 1 : Export to WebGL from Unity3d
Open your project in Unity 3d.
Go to file and click on build settings and choose WebGL.
Step 2 : Create Web-App in Azure and Configure it.
Now once you've exported your project, go to Azure portal and create a Web app using quick create.
Give it a suitable URL as shown in the screenshot below.
When your app is created go to the configure options of the app. Here, turn on the option which says "Edit in Visual Studio Online". This will allow us to edit and write code to our app in visual studio online.
Go back to the dashboard of the app and click on the "Edit in Visual Studio online" option on the bottom right side.
This will take you to a new window where it will load your web-app into Visual Studio online.
Now in this window, create a new file in "wwwroot" folder. Name that file "web.config"
Once the file is created, add the following code to the file and save it.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<staticContent>
<remove fileExtension=".mem" />
<mimeMap fileExtension=".mem" mimeType="application/octet-stream" />
<remove fileExtension=".data" />
<mimeMap fileExtension=".data" mimeType="application/octet-stream" />
</staticContent>
</system.webServer>
</configuration>
This will basically configure your web-app to handle .mem and data files of your game.
Step 3 : Upload the release files
Now it's time to upload your release files that you just created from the unity export.
Go to the dashboard of your app and click on WebMatrix icon at the bottom.
WebMatrix is a cloud based web development tool.
Now in WebMatrix copy all the files and folder (except for .htaaccess file) from your build folder to the WebMatrix. You can do this simply by drag and drop.
Wait for all the files to finish copying.
Now your game is hosted in the Web-app and it should be able to be accessed via your Web-app URL.
Type in your Web-app URL in the browser to check it. The first load is probably going to take some time so be patient.
I'm also gonna leave the URL of the game I uploaded, you may check that as well :)
This is how it's going to look like. I hope you would've liked this article. Do let me know about your comments and suggestions :) Have Fun :)