Autoscaling Azure with WASABi – Part 2

I gave an Autoscaling Azure talk at the Brisbane Azure User Group (BAUG) on the 18th April 2012. This series of posts will walk through the demo I put together for the talk using the Autoscaling Application Block (WASABi).

What are we building?

We will be building the application that performs the autoscaling using the Autoscaling Application Block (WASABi) from the Enterprise Library 5.0 Integration Pack for Windows Azure. I decided to build a simple console application to host the autoscaler locally for the purposes of the demo. For simplicity I also used a local service information store and local rules store. More on these stores in the next parts of the series.

In a real world situation you would probably want to host the autoscaler in an Azure cloud service worker role and the stores in an Azure storage account.

Create Storage Account

Didn’t we just create a storage account in part 1? Yes we did, but that was for the web application that we will be scaling. We now need to create a storage account that will hold the data points that the autoscaler will use to evaluate its scaling rules.

The data points store must be hosted in an Azure storage account as the Autoscaling Application Block uses the upsert feature of the Azure table storage that is not supported by the local emulator.

Log in to the Windows Azure preview portal and click on the NEW button. Select Storage > Quick Create and fill in the details for your storage account. I have selected baugautoscalingdata as my url and Southeast Asia as my region since I live in Australia. The subscription I am using is the subscription linked to my MSDN. I have also disabled geo-replication for the demo storage account. Click on Create Storage Account.

baugautoscalingdata - create storage account

Wait for the storage creation to complete successfully. You should be rewarded with an Online status.

baugautoscalingdata - Storage online !

Create Console Application

Now on to the actual console application that will host the autoscaler. Click on New Project in Visual Studio and select Visual C# > Windows > Console Application. I have a folder C:\Projects\WasabiDemo where I am creating the solution with the name, ConsoleAutoscaler. Click OK to create the project.Console Application Project

Right click on the ConsoleAutoscaler project and select Properties. Ensure that the Target Framework is set to .NET Framework 4 and not the default .NET Framework 4 Client Profile. Save.

Right click on the ConsoleAutoscaler project and select Manage NuGet Packages … Select the Online tab on the left of the dialog and then in the search box type the word wasabi. Hit Enter.

Select the Enterprise Library 5.0 – Autoscaling Application Block package and click Install.NuGet: Enterprise Library 5.0 – Autoscaling Application Block

A number of dependencies are installed into the project in addition to schemas to manage the service information and local rules stores.

Solution Explorer

Open the Program.cs file and update with the following code:

 
using System;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.WindowsAzure.Autoscaling;

namespace ConsoleAutoscaler
{
  class Program
  {
    static void Main(string[] args)
    {
      try
      {
        var scaler = EnterpriseLibraryContainer.Current.GetInstance<Autoscaler>();
        scaler.Start();

        while (true)
        {
          System.Threading.Thread.Sleep(10000);
          Console.WriteLine("{0} - running", DateTime.Now);
        }
      }
      catch (Exception exp)
      {
        Console.WriteLine(exp.Message);
        Console.Write(exp.StackTrace);
      }
      Console.ReadKey();

    }
  }
}

That is all there is to setting up the autoscaler using the Autoscaling Application Block. The next steps will be to configure the autoscaler and the service information and local rules stores.

About these ads

4 thoughts on “Autoscaling Azure with WASABi – Part 2

  1. Pingback: Windows Azure Community News Roundup (Edition #33) - Windows Azure - Site Home - MSDN Blogs

  2. Pingback: Windows Azure Community News Roundup (Edition #33) - Windows Azure Blog

  3. Pingback: Windows Azure Community News Roundup (Edition #33) | Platform as a Service Magazine

  4. Pingback: Reading Notes 2012-09-03 | Matricis

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s