Deploy Unity3D Game in Windows Azure

Instead of playing games I enjoy developing them. I develop 3D games with Unity and Unreal game engines. I always want to embed a demo version of some of my games in my blog that is hosted on Azure. I uploaded the files from the final build of the game to Azure but it didn't help me. I got a 404.3 error. Most servers require no configuration at all. We need to just upload the .unity3d file and the accompanying HTML file but it doesn't work on Azure. On Azure we need to add a custom Multi-purpose Internet Mail Extensions (MIME) type.

MIME types

MIME types form a standard way of classifying file types on the Internet. Internet programs such as web servers and browsers all have a list of MIME types, so that they can transfer files of the same type in the same way, no matter what operating system they are working in. There are many predefined MIME types, such as GIF graphics files and PostScript files. It is also possible to define your own MIME types.

In addition to e-mail applications, Web browsers also support various MIME types. This enables the browser to display or output files that are not in HTML format.

If you try serving MP4 files from your webserver it will also throw a 404.3 error because it blocks requests for unknown MIME types since Azure does not want to serve out random content. We really don't want our web server to serve any random files, like .mdb (Access database), .passwd (password), .inc (source include) or other files that may have landed in our web content directory. So we land on the safe side and block all unknown extensions by default from being served. To make it easy to troubleshoot, we return the special error code 404.3.

 

Server Error in Application "<application name>"
--------------------------------------------------------------------------------
HTTP Error 404.3 - Not Found
HRESULT: 0x80070032
Description of HRESULT: The page you are requesting cannot be served because of the Multipurpose Internet Mail Extensions (MIME) map policy that is configured on the Web server. The page you requested has a file name extension that is not recognized, and is not allowed.



error

It is very easy to add MIME types to Azure. So let us see how to do that.
  1. Get access to your site's home directory. I configured FTP access to my site with FileZilla, Definitely you can use any other FTP client application also. You can get FileZilla from here. Download and install it in your Computer.
  2. Log into your Azure portal.
  3. Go to your website's dashboard.
  4. Download the publish profile.

    Download the publish profile

  5. In FileZilla go to “File -> Site Manager”.

    Site Manager

  6. Finally connect to your website with username and password as shown in your publish profile and you will see the following three folders:

    • Site: This is the folder where your website specific files are located.
    • Logfiles: This is the folder where your website specific Diagnostics LOG files are located.
    • Data: Site data is stored here.

  7. In the site folder under the root directory edit the “web.config” file or create it.
  8. Make some changes as follows:
    1. <configuration>  
    2.    <system.webServer>  
    3.       <staticContent>  
    4.          <mimeMap fileExtension=".unity3d" mimeType="application/vnd.unity" />  
    5.       </staticContent>  
    6.    </system.webServer>  
    7. </configuration>   
    The MIME type for Unity webplayer content is:

    application/vnd.unity

    And the file extension for the Unity webplayer files are:

    .unity3d

    webplayer files

    If you're editing htaccess files on your server, you need to add this:

    AddType application/vnd.unity unity3d

  9. You are now done. Restart your website from the dashboard. Now you can show your developed game to the world.



    Similarly if you want to serve MP4 files then you can add the following in the “web.config” file.
    1. <mimeMap fileExtension=".mp4" mimeType="video/mp4" />  
    2. <mimeMap fileExtension=".m4v" mimeType="video/m4v" />  

You can check my embed Unity games here.

Unity games


Similar Articles