Category Archives: Azure

Azure: Links, News and Resources (3)

Previous Post

More links I collected during my work and research.

Cyan – Simpler than Azure
Cyan is a .NET dynamic client for the Azure Table Storage REST API.

Azure Table Storage & Dynamic TableServiceEntity

richorama / AzureSugar
Syntactic sugar to make Azure development a little sweeter
Support is also available for using dynamic types (or dictionaries) to insert and query table storage.

Azure Table Storage with dynamic entities objects

WindowsAzure / azure-sdk-for-node

Accessing Azure Role Environment information from NodeJS

Windows Azure Startup task to run npm install to avoid deploying node modules

Leveraging Node.js’ libuv in Windows Azure

Getting the samples to work on the Azure Node.js SDK

Microsoft will add Linux virtual machines to Windows Azure

Create Hosted Service using Windows Azure Management API

Microsoft Windows Azure PaaS Gets Node.js Update

How to deploy WordPress using the Windows Azure SDK for PHP WordPress scaffold

Advertising Company Adopts Cloud Computing, Gets 400 Percent Improvement

Game Developer Meets Demand and Prepares for Success with Scalable Cloud Solution

What is Windows Azure?

Azure On GitHub

Azure: Running Multiple Web Sites in a Single WebRole

Deploying independent web applications to Windows Azure using single web role

Modificar el tiempo de vida del token proporcionado por Windows Azure AppFabric Access Control

Windows Azure Multi Application
Windows Azure Multi Application is a complete sample solution that allow deploy dinamically aplications to existing role instance.
After deploy admin tool new application can be deployed, without modify initial azure deployment. Each application can be deployed independently and can be of different types; ASP.NET WebForms, ASP.NET MVC, Windows Service, Console Application…

How to combine a Worker Role and an MVC4 Web Role into a single Azure instance

Hadoop Streaming and F# MapReduce

Windows Azure Architecture Guide – Part 2 – Code Samples

Windows Azure + a pinch of UK

Using Amazon and Azure Cloud Services in your Delphi XE2 and C++Builder XE2 Applications

What’s new in Windows Azure

Microsoft Azure gets an open source rival

Introduction to the Hadoop on Azure Interactive JavaScript Console

Node.JS in Windows Azure

Azure price cuts, bigger databases, now with node.js and MongoDB support, Hadoop on its way

Improved Developer Experience, Interoperability, and Scalability on Windows Azure

Azure Node.js Developer Center

Deploying Node.js Applications to Windows Azure via Blobs or Git Sync

Ten Basic Troubleshooting Tips for Windows Azure

Now Available! Updated Windows Azure SDK & Windows Azure HPC Scheduler SDK

My Links

Social Games Programming (Part 8) Adding Node.Js

Previous post

In the previous post, we explored the game processing in the current Windows Azure Toolkit for Social Gaming. Now, it’s time to add Node.js as game server, in our Tic Tac Toe simple game.

All the Game Service client code is game agnostic. And it can be changed to use another services. In this post, I will change the play move processing to be directed to a Node.js instance.

You need to download the node folder from my GitHub:

Then, follow these steps:

1 – Download and setup the Windows Azure Toolkit for Social Gaming version 1.1.1, from:

1 – Install Node.js for Windows, from

2 – Change to the server folder, and execute this command line:

npm install

The library is downloaded and installed in a node_modules subfolder:

This is the folder tree:

3 – Start the node.js server:

node gameex.js

The server starts to listen:

4 – Copy the client folder to your SocialGaming.Web project folder. Web.config, BaseController.cs, TicTacToeController.cs files will be replaced. New files will be added: Scripts\game\GameServiceNodeJs.js, Areas\Samples\Views\TicTacToe\NodeJs.cshtml.

5 – Open the solution in Visual Studio 2010 (run as administrator) and add these files to SocialGaming.Web project. The new Game Service for Node.js:

The new TicTacToe view that uses Node.js:

The new action in the replaced TicTacToe controller:

There is a new entry in the web.config file:

The replaced BaseController reads that setting:

6 – Start the application (it should run as to be accepted by the Federated Security running in ACS portal). See the invite URL:

7 – Browse to /Samples/TicTacToe/NodeJs:

8 – The client connects with the Node.js game server:

My browser doesn’t understand the WebSocket version implemented in the server library. Then, fallback to use xhr long polling.

9 – Open a new browser, in a private session, with the URL provided by the step 6

10 – These are the two players. The left one played at top left cell. The right player receives the new move and update its view.

11 – See the server console: the move was received and broadcasted to the game participants:

Nice! Homework: add the Node.js to a worker role (see @ntotten post NodeJS on Windows Azure).

Next topics: explain in detail the server code (it supports client that uses plain TCP sockets instead of, so you can program a client in other platforms, from Silverlight to iPhone to Android).

Keep tuned!

Angel “Java” Lopez

Social Games Programming (Part 7) Game Moves Processing

Previous Post
Next Post

In this post, I want to discuss the game play processing in Tic Tac Toe. It involves many pieces, from Razor view using Javascript to Web Role, to Azure Blob Storage.

These are the javascript files referenced in Tic Tac Toe view (at SocialGame.Web/Areas/Samples/Views/TicTacToe/Index.cshtml):

<script src="@Url.AreaContent("Scripts/jQuery.tmpl.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/knockout-1.2.1.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/ServerInterface.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/GameService.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/game/UserService.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeBoard.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeGame.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeViewModel.js")" type="text/javascript"></script>
<script src="@Url.AreaContent("Scripts/game/TicTacToeController.js")" type="text/javascript"></script>

As I wrote in the previous post, ServerInterface, GameService and UserService are game-agnostic components. They could be used in any game. For each new kind of game X, you must implement XBoard, XGame logic, XViewModel and an appropiate XController.

At the end of that view, there is the creation of the game-agnostic services:

var apiURL = "@this.ViewBag.ApiUrl";
var blobURL = "@this.ViewBag.BlobUrl";
var si = new ServerInterface();
var gs = new GameService(apiURL, blobURL, si);
var user = new UserService(apiURL, blobURL, si);

The @this.ViewBag properties are filled in the ASP.NET MVC controller (see BaseController.cs)

The creation of the game controller:

// check for canvas, show an "Upgrade your browser" screen if they don't have it.
var canvas = document.getElementById('board');
if (canvas.getContext == null || canvas.getContext('2d') == null) {
var board = new TicTacToeBoard(canvas);
var game = new TicTacToeGame();
var controller = new TicTacToeController(viewModel, gs, board, game);

But the interesting part is in the controller constructor:

function TicTacToeController(viewModel, gameService, board, game) {
    this.viewModel = viewModel;
    this.gameService = gameService;
    this.board = board; = game;
    this.started = false;
    var controller = this;
    this.board.onMove = function (x, y) { controller.onMove(x, y); };

Notice the this.board.onMove: the controller register itself to process new moves detected by the board component. At its start method, the controller register itself to process game service updates:

        function (queue) { controller.processGameQueue(queue); },
        function (action) { controller.processAction(action); }

Let’s examine the processing of game moves.

1 – The board component detects a click, then it sends a new move to controller (using the onMove callbalk)

2 – The controller sends the new move to game logic, to update state (I omitted the view model in this sequence/graph)

3 – The controller sends the new move to game service.

4 – The game services sends a new command to web role, using the server interface

5 – The Web Role API receives the new command

6 – The command info is appended to the game status blob, at Azure storage

Now, the other client processing:

1 – The game service, using a timer, polls the game status, calling the service interface

2 – The service interface, using JSONP, retrieves the current game status from Azure Blob storage

3 – If a new move is detected, the game service calls a callback function provided by the controller (game service has no reference to controller).

4 – The controller sends the new move to game logic, updating state (I omitted the view state here)

5 – The controller sends the new move to board component, to update the canvas

A key point: the controller knows NOTHING about the service interface, WCF Web API, blob storage. So, you can change the game service to route and detect new moves in other ways. Next post: modify game service to use a Node.js server for game move processing.

Keep tuned!

Angel “Java” Lopez

What is Windows Azure?

Past year, I wrote many blog post about Azure programming. Maybe, you know about cloud computing in general, but not about Azure in particular. Today, thanks to Windows Azure + a pinch of UK published by Eric Nelson (@ericnel), I found this video, that explain in simple terms the key technical pieces of Azure:

For more information about the video, see Steve Marx (@smarx) post:

What is Windows Azure? (a Hand-Drawn Video)

It has an interesting section title: “How I Made It”.

Notice the difference of compute nodes and storage nodes. Both service can be emulated in your local machine, thanks to Azure tools for Visual Studio.

My links about azure:

A post about Azure, games and Node.js is comming.

Keep tuned!

Angel “Java” Lopez

Social Games Programming (Part 6) Testing Game and Service with TDD and QUnit

Previous Post
Next Post

In my previous post, I presented the new version of Windows Azure Toolkit for Social Games. It has simple games to demonstrate the use of Javascript, HTML 5 canvas, game moves processing, Azure worker roles and web roles. Let’s explore in this post the making of client game logic, in Javascript, using TDD and QUnit.

There are online tests at:

Let’s run the Tic Tac Toe Game Logic tests:

This page is using QUnit for client Javascript unit testing. I wrote about that library at:

TDD with Javascript and QUnit

The above page is testing the Tic Tac Toe logic. Remember, each game is implemented in parts, the logic is one of them:

The client code resides in TicTacToeGame.js inside the SocialGames.Web project. Their first lines:

TTTColor = { Empty: 0, Cross: 1, Circle: 2 };
function TicTacToeGame() {
    this.board = [
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty],
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty],
     [TTTColor.Empty, TTTColor.Empty, TTTColor.Empty]
TicTacToeGame.prototype.move = function (x, y, color) {
    this.board[x][y] = color;
TicTacToeGame.prototype.isEmpty = function (x, y) {
    return this.board[x][y] == TTTColor.Empty;

The client test page (TicTacToeGameTest.cshtml) was built at the same time, using a TDD (Test-Driven Development) approach. Look at first tests:

test("Create Empty Board", function () {
    var game = new TicTacToeGame();
    for (var x = 0; x < 3; x++)
        for (var y = 0; y < 3; y++)
            ok(game.isEmpty(x, y));
    equal(game.isTie(), false);
    equal(game.hasWinner(), false);
test("Valid Moves on Empty Board", function () {
    var game = new TicTacToeGame();
    for (var x = 0; x < 3; x++)
        for (var y = 0; y < 3; y++) {
            ok(game.isValid(x, y, TTTColor.Cross));
            ok(game.isValid(x, y, TTTColor.Circle));
test("No Winner in Empty Board", function () {
    var game = new TicTacToeGame();
    equal(game.getWinner(), TTTColor.Empty);
test("Get Winner in First Row", function () {
    var game = new TicTacToeGame();
    game.move(0, 0, TTTColor.Cross);
    game.move(1, 0, TTTColor.Cross);
    game.move(2, 0, TTTColor.Cross);
    equal(game.getWinner(), TTTColor.Cross);
    equal(game.isTie(), false);
    equal(game.hasWinner(), true);

The idea is to take baby steps, one test at a time, designing the game logic “API”, its expected behavior. In this way, you expend less time debugging in a dynamic language like Javascript, and you gain a test suite that can save your day in case of major refactoring. Look at the Four In A Row logic and client tests: you will find a similar approach.

Ok, not all can be easily tested, or build using TDD. Some of the game-agnostic services are using Ajax and Blob Storage, and to test them you must consider asynchronous Ajax calls. You can check:

(You must be logged in using your Facebook or Windows Live ID, an example of use of Federated Security and Access Control Service (ACS))

This time, the system under test is the game-agnostic Server Interface:

There are some tricks in the test code (ServerInterfaceTest.cshmlt), an excerpt:

test("Call User/Verify", function () {
    var success = function (result) { ok(true); start(); };
    var error = ajaxGetError;
    si.sendAjaxGet(apiURL + "user/verify", success);

expect is a QUnit function that prepare the framework to receive 1 ok(true) sometime during the test run. That confirmation is included in callback function success that it will be called after the successful processing of the asynchronous call .sendAjaxGet. Async life is not easy 😉

More code analysis is coming. And some adapt to use Node.js as game server.

Keep tuned!

Angel “Java” Lopez

Social Online Games Programming (Part 5) New Azure Toolkit

Previous Post
Next Post

Two weeks ago, a new version of Windows Azure Toolkit for Social Games was released. See @ntotten posts:

Windows Azure Toolkit for Social Games Version 1.1.1
Windows Azure Toolkit for Social Games Version 1.1

The new version implements two simple HTML5 games: tic-tac-toe and four-in-a-row, backed up by ASP.NET MVC views, WCF Web API services, ACS federated security, and Azure Storage. You can play them online at:

I think this is a more clear example than the previous one (Tankster) that was great but a bit overwhelming ;-). Let’s dive into some implementation details of this new example.

Totten wrote:

The biggest change we have made in this release is to separate the core toolkit from the Tankster game. After we released the Tankster sample game we received a lot of feedback asking for a simpler game that developers could use to learn. To meet this need we developed two simple games, Tic-Tac-Toe and Four in a Row, and included in the toolkit. The Tankster game is now available separately as a sample built on top of the toolkit.

While the new games included in the toolkit are much simpler than Tankster, they still show the same core concepts. You can easily use these samples as a starting point to build out any number of types of games. Additionally, you will find that many of the core components of the game such as the leaderboard services, game command services can be used without any modification to the server side or client side code.

In my previous post, I mentioned a minor but important change in game action processing: any game logic was removed from server code. Adopting this approach, you can write new games without changing the ASP.NET MVC code. You still can add server side code if you want (to have more control over the actions, to avoid player cheating, etc..) but it is interesting to have a base code with game-agnostic code.

Opening the solution in Visual Studio, you will find Javascript files used by the two games. You can write a new game, reusing these files:

The games are implemented as areas:

You could add new games and publish them as NuGet packages.

Visually, the client Javascript code is organized as:

Each game X (TicTacToe, FourInARow, yours) has:

XGame: the game logic

XBoard: to draw board on canvas and to detect click events on it

XViewModel: containing the player and other data to be used at view rendering (the example uses knockout.js, an MVC in Javascript)

XController: to process new events and to coordinate the above elements

The generic part:

UserService: methods related to users: login, get friends, etc.

GameService:  play moves, receives new moves, other actions.

ServerInterface: Ajax calls (using GET, POST, JSONP, Azure storage…) that are used by the implemention of User and Game Service.

Topics for next posts: analyze the Javascript code, the use of Canvas, Javascript tests using QUnit, communication with server using Ajax, change the Game Service (Javascript) to use a Node.js server.

Keep tuned!

Angel “Java” Lopez

Azure: Links, News and Resources (2)

Previous Post
Next Post

More links related to Azure:

The Windows Azure Platform[2] is a Microsoft cloud platform used to build, host and scale web applications through Microsoft data centers. Windows Azure Platform is thus classified as platform as a service and forms part of Microsoft’s cloud computing strategy, along with their software as a service offering, Microsoft Online Services. The platform consists of various on-demand services hosted in Microsoft data centers and commoditized through three product brands. These are Windows Azure[3] (an operating system providing scalable compute and storage facilities), SQL Azure (a cloud-based, scale-out version of SQL Server) and Windows Azure AppFabric (a collection of services supporting applications both in the cloud and on premise).

Moving to Windows Azure

Build 2011: Windows Azure Tackles the ‘One True Login’ Puzzle

Microsoft to eat its own cloud dog food with Photosynth

Command-Query Separation on Windows Azure

How to Manage Expiration of Blob Content

Windows Azure Design Patterns, Part 1: Architectural Symbols

Windows Azure Accelerator for Web Roles Version 1.1

Running Processes in Windows Azure

pekkah / AzureSamples

Exercise 1: Using Worker Role External Endpoints

Building Web APIs in Windows Azure with WCF to reach any device

pofallon / node-azure
A node.js library for accessing the Windows Azure REST API’s

Introducing Geo-replication for Windows Azure Storage

Windows Azure Tables: Introducing Upsert and Query Projection

Windows Azure Blobs: Improved HTTP Headers for Resume on Download and a Change in If-Match Conditions

CloudCopy Command Line Tool

Windows Azure Toolkits for Devices – Now With Android!

Microsoft rolls out Windows Azure toolkit for Android

Windows Azure SDK for PHP

Azure Tip: Consider Remote Desktop when Planning Role Endpoints

Memcached in Windows Azure

NodeJS on Windows Azure

Using Windows Azure to use as a TCP Server

Windows Azure Tip: Go Beyond 5 Endpoints per Role, beyond 25 per Deployment

Lightweight Tracing to Windows Azure Tables

Using ELMAH in Windows Azure with Table Storage

Windows Phone 7 Push Notification QuickApp / Web Service (With Azure Publishing Instructions!)–Web-Service-With-Azure-Publishing-Instructions

Various Options to Manage Session State in Windows Azure

Windows Azure & WF 4.0 – Creating a Workflow-Driven WorkerRole

Microsoft announced Windows Azure Storage Analytics

Azure Cloud to Capture RenderMan

igrating SQL server Data to SQL Azure using BCP << Paras Doshi

Using Windows Azure Blob Storage and CDN with WordPress

Practical Testing Techniques for Windows Azure Applications

Daytona: Iterative MapReduce on Windows Azure

Connecting to SQL Azure from Ruby Applications

Ideas about NoSql on Windows Azure: Azure Storage

Architecture of Tankster– Scale (Part 2)

Windows Azure CDN Helpers

Social Gaming on Windows Azure

Extending the Windows Azure Accelerator for Web Roles with PHP and MVC3

Ajax, Cross Domain, jQuery, WCF Web API or MVC, Windows Azure

smarx / blobedit
Simple UI (based on Ace) to edit code files in Windows Azure blob storage

sriramk / winazurestorage
Python client wrapper for Windows Azure storage

Azure BlobStorage Javascript Library

Using Windows Azure Page Blobs and How to Efficiently Upload and Download Page Blobs

Building Java applications on Windows Azure gets easier with the new version of the Eclipse plugin

My Links

Keep tuned!

Angel “Java” Lopez