Construct 2 Windows Azure Plugin

Index

  1. Register your Azure Mobile Services account
  2. Create a new mobile service
  3. Create a table for the example .capx
  4. Change plugin properties in example .capx
  5. Export Project
  6. Enable User Authentication
  7. Restrict permissions to authenticated users

1.) Register your Azure Mobile Services account

To get started you need a Windows Azure account that has the Windows Azure Mobile Services feature enabled.
  • If you don't have an account, you can create a free trial account in just a couple of minutes. For details, see Windows Azure Free Trial. The process is simple – takes 2-3 minutes. You will be asked to enter your credit card details for identity verification. The spending limit on your card will be automatically set to £0.00. If at the end of your free period you’d like to remove the spending limit, you can. Otherwise it will remain in force forever
  • If you’re a student or academic you can register for azure in education pass for FREE see http://www.windowsazure.com/education
  • If you have an existing account but need to enable the Windows Azure Mobile Services preview, see Enable Windows Azure preview features.

2.) Create a new mobile service

Follow these steps to create a new mobile service.
  • Log into the Management Portal.
  • At the bottom of the navigation pane, click +NEW.
image08.png

This displays the New Mobile Services dialog.

image16.png
  • Expand Mobile Service, then click Create.
  • In the Create a mobile service page, type a subdomain name for the new mobile service in the URL textbox and wait for name verification. Ensure Create a new Database is selected and choose the Region you wish to have the service hosted. Once the verification completes, click the right arrow button to go to the next page.
image09.png

This displays the Specify database settings page.

image02.png
  • In Name, type the Name of the new database, then type Login Name, which is the administrator login name for the new SQL Database server, type and confirm the Password, select the Region you want the database to be hosted and click the check button to complete the process. You have now created a new mobile service that can be used by your Construct 2 game for Windows 8.

3.) Create a table for the example .capx

The example .capx refers to a table called People, which contains the name, age and gender of various individuals.
  • In the Management Portal select DATA from the top navigation.
image07.png
  • At the bottom of the navigation pane, click CREATE.
image13.png
  • Enter People as the table name and leave the permissions as Anybody with the application key.
image10.png

4.) Change plugin properties in example .capx

  • Ensure you’ve downloaded the Azure Mobile Services Plugin for Construct 2. To install the plugin drag the .c2addon file into the Construct 2 window.
  • Download the sample .capx file that accompanies this plugin and launch it.
  • Go to your Azure Mobile Services dashboard and make a note of your mobile service URL.
image17.png
  • At the bottom of the navigation pane, click MANAGE KEYS.
image17.png

This displays the Manage Access Keys dialog.
  • Make a note of your Application Key.
  • Open up Construct 2 again and in the Projects Panel locate the AzureForWindows8 object: Object Types ->Functionality ->AzureforWindows8. Select it and in the Properties Panel enter the App URL and App Key that you made a note of.
image14.png

5.) Export Project

  • To export your Windows 8 project follow this official Construct 2 guide: Exporting from Construct 2.
  • Make sure you have the Mobile Services SDK installed on your local computer or virtual machine.
  • Open up your exported project and in the package.appxmanifest Capabilities tab check Internet (Client).
  • Ensure that the Windows Azure Mobile Services JavaScript Client is listed under Reference in the Solution Explorer.
image18.png
  • If the reference doesn’t exist, you can add it by right clicking on the References folder in the Solution Explorer and selecting Add Reference. You should see the option Windows Azure Mobile Services JavaScript Client which can be checked to add it to the project.
image19.png

6.) Enable User Authentication

To enable authorisation the plugin looks for a dummy table called ‘Identities’ which returns authorisation information for the plugin to use.
  • In the Management Portal select DATA from the top navigation.
image07.png
  • At the bottom of the navigation pane, click CREATE.
image13.png
  • Enter Identities as the table name and change INSERT, UPDATE and DELETE permissions to Only Scripts and Admins. Change READ permission to Only Authenticated Users.
image15.png
  • In the Management Portal, click the Data tab, click the Identities table and select SCRIPT from the top navigation.
image11.png
  • In the OPERATION dropdown select Read and replace all the code with the following:
function read(query, user, request) {
    var result = {
        id: query.id,
        identities: user.getIdentities()
    }
    if (query.id) {
        request.respond(200, result)
    } else {
        request.respond(200, [result])
    }
}


image04.png
  • At the bottom of the navigation pane, click SAVE.
image03.png

Next you need to follow the steps to register your app for each provider:
  • Back in the Management Portal, click the Identity tab, enter the app identifier and shared secret values obtained from your identity provider, and click Save.
image00.png
image03.png

6.) Restrict permissions to authenticated users

  • In the Management Portal, click the Data tab, and then click the People table.
image06.png
  • Click the Permissions tab, set all permissions to Only authenticated users, and then click Save. This will ensure that all operations against the People table require an authenticated user.
image12.png
image03.png

You can now export the sample .capx and should have full Azure Mobile Services functionality working inside your Construct 2 project.

Last edited Feb 27, 2013 at 10:26 PM by thehen, version 8

Comments

No comments yet.