Book Review: Microsoft Windows Azure Development Cookbook

Cloud computing is certainly one of the hot topics in today’s technology landscape. As such, more and more books on the topic are starting to emerge. There are books on cloud computing in general. There are books providing an overview, as well as specifics, on major cloud platforms such as Windows Azure and Amazon AWS. But there are very few that provide quick, bite sized solutions to real-world situations. Neil Mackenzie’s Microsoft Windows Azure Development Cookbook is that book. The book contains over 80 recipes which are applicable in many Windows Azure projects. There are recipes on nearly all aspects of the Windows Azure platform – Windows Azure storage services, diagnostics, management, security, SQL Azure, Windows Azure AppFabric, and much, much more.

Let’s say you need to control access to some files you’re storing in blob storage. One way to do that is via a Shared Access Signature. Sure, you can look up information on blobs and containers on MSDN, and try to piece together what is needed to create and use a Shared Access Signature. Or, you can open up the “Creating a Shared Access Signature for a container or blob” recipe in this book and have all the information, including a clean, reusable code example, at your fingertips. I don’t know about you, but I find the latter a much easier, and faster, way to get what is needed.

Recently I was working on a project where I needed to use the Windows Azure Service Management API. The Windows Azure Service Management API, like many of the APIs for the Windows Azure platform, is based on a RESTful interface. While this has many wonderful benefits, writing terse code is not one of them. Currently there isn’t a nice .NET wrapper library to make a developer’s life easy. I recalled from my reading of Microsoft Windows Azure Development Cookbook that there was a recipe for retrieving the properties of a Windows Azure hosted service. In fact, there’s a whole chapter of recipes for working with the Windows Azure Service Management API! I quickly turned to the recipe I needed, found the information (including a great little code sample to make working with the API easier), and was on my way.

You don’t have to read this entire book, although I would encourage you to do so, to feel like you’re getting your money’s worth. The recipe’s that Neil has put together are simple enough that they stand on their own, and yet complete enough that you understand what you’re doing and why. Each recipe begins with a brief overview of the situation, proceeds in to a section on how to accomplish the goal, and then wraps up with brief discussion on how it all works. Where applicable, the recipe will also include nuggets of information providing insight into problems you may encounter and tips on solving them, along with references to allow you to learn more about the topic at hand.

Like any good cookbook, Microsoft Windows Azure Development Cookbook is chock-full of tasty recipes that are easy to understand, fun to try, and leave you satisfied . . . and maybe even wanting a little more! I have a lot of technical reference books in my collection. However, there are very few that I keep within arm’s reach. Neil Mackenzie’s Microsoft Windows Azure Development Cookbook is an easily referenced book that is always within arms’ reach for me, as it should be for anyone working with the Windows Azure platform.

Many New Windows Azure Platform Features – Part 2

The first day of BUILD sure was exciting.  We got to see a lot of what Microsoft has been working on for the next version of Windows.  I’m really excited about what the feature holds.  It’s sure to be a fun year or so while Microsoft continues to build and gather feedback on Windows 8.

While day 1 was exciting, there wasn’t a lot in the first keynote if your primary development area is Windows Azure.  That sure changed with the day 2 keynote!  Day 2 was all about the developer, and Windows Azure received a lot of attention!  Below are just a few of the Windows Azure nuggets of awesomeness unveiled on day 2 at BUILD.  I’ll have more details on these new updates coming soon.

Windows Azure Toolkit for Windows 8

Much like the Windows Azure toolkits for Windows Phone 7, iOS, and Android made it very easy to write Windows Azure applications/services for those platforms, the Windows Azure Toolkit for Windows 8 promises to make it easy to write cloud enabled applications for the upcoming Windows 8.  I’m eager to get my hands on the Windows 8 developer preview and trying out this new toolkit.

Windows Azure SDK 1.5 (a.k.a. “Windows Azure Tools for Microsoft Visual Studio 2010 – September 2010”)

The latest Windows Azure SDK includes several new features and enhancements.

  • Updates to csupload.exe – Allows you to upload service certificates.
  • New csencrypt.exe tool

There is a new command line tool called csencrypt.exe which helps you to create and encrypt passwords for managing Remote Desktop connections to Windows Azure instances.  With this tool, you can create a new certificate that can be used for encrypting passwords, view all the certificates on your machine that can be used for encrypting passwords, and create a new encrypted password.  The really nice aspect here is that now it is very easy to change a password and/or certificate thumbprint that is used in your Remote Desktop connection.  Meaning, you can now use csencrypt.exe to generate the new password, copy and paste it into your CSCFG, and update your configuration in the portal.  Nice and easy!

  • Tooling enhancements

There are also a few welcome enhancements to the tooling to make deployments a little bit nicer.  One is better package validation as part of the deployment process from within Visual Studio.  For example, let’s say I configured Remote Desktop, but I forgot to upload the certificate to the service in the portal.  Visual Studio will provide a validation warning and halt the deployment.

There is also a re-architected emulator for improved performance and fidelity between local and cloud development.

  • Geo-Replication for Windows Azure Storage

This is HUGE!  I’m often asked about disaster recovery options with Windows Azure storage (in the event of a major disaster with a Windows Azure data center).  There really wasn’t a platform feature that solved this problem, until today.  Previously customers would have to develop their own solution – something that was somewhat of an adoption barrier.  Now, Windows Azure storage geo-replication is enabled for blobs and tables!  This new feature will asynchronously replicate your data to another Windows Azure data center within the same region (for example, North Central US to South Central US, not a US data center to a European data center).

More information on what’s new in Windows Azure SDK 1.5 can be found on MSDN at

Windows Azure AppFabric SDK 1.5

The latest Windows Azure AppFabric SDK will allow you to work with the latest release of the Windows Azure AppFabric Service Bus.  This enables support for features such as queues, topics, and subscriptions.  Previously these features were released as a CTP release back in May 2011.  Today they’re fully available and supported as part of the Windows Azure Platform.  Commence rejoicing now!

Sweeeeeeta!  How do I get this awesomeness?

You can download both of these very easily from the Web Platform Installer. Once the Web PI is launched, simply go to the Products section and scroll nearly to the bottom (or search for “Azure” in the search box).

As always, be sure to visit the Windows Azure team blog for the official announcements and links to more details.

Deploying My First Windows Azure AppFabric Application

In my last post I walked through the basic steps on creating my first Windows Azure AppFabric Application.  In this post I’m going to walk through the steps to get that basic application deployed and running in the new Windows Azure AppFabric Application Manager.

Before I get started, I wanted to point out a few important things:

To get started, I need to go to the AppFabric labs portal at  From there I go to the “AppFabric Services” button on the bottom of the page, and then the “Applications” button in the tree menu on the left.  I had previously requested and been granted a namespace, so my portal looks like the screenshot below:

I noticed that I had namespaces related to Windows Azure storage and SQL Azure.  This is separate from any other storage or SQL Azure you may already have.  The CTP labs environment provdes one SQL Azure database to get started with, but you can’t create new databases as the provided user doesn’t have the necessary rights (see this forum post for additional details).  I can access Access Control Services v2 by highlighting my namespace and then clicking on the “Access Control Portal” green toolbox in the top ribbon.  To launch the Windows Azure AppFabric Application Manager, I simply highlight my namespace and then click on the “Application Manager” blue icon in the top ribbon.  Let’s do that.

From here I can see any Windows Azure AppFabric Applications that are deployed as well as some application logging (within scope of the AF App Manager).  In order to create a new application, I can click on the “New Application” link on the Application Dashboard, or also the “New Application” option under the “Actions” menu in the upper-right hand corner of the dashboard.

Let’s assume for now that I am not complete with my application, but I would like to reserve the domain name.  This is similar to creating a new Windows Azure hosted service (reserves the domain name but doesn’t require a package be uploaded to Windows Azure at the time).  When I create that new application, I am presented with a dialog that lets me upload the package and specify the domain name I’d like to use.

When I click on the “Submit” button, I will see a progress dialog to show me the status of the package creation.  This only takes a few seconds.

Now that my application is created in the Windows Azure AppFabric AppManager, I can click the name of the application to open a new screen containing all sorts of details about the application.

From this screen I can see properties related to the application, any containers used by my application (great explanation in Neil’s blog post), the endpoints I have created, any referenced services, as well as some monitoring metrics for my application.  At this point these fields are empty since I haven’t deployed anything yet.  I also noticed that I can drill into details related to logging, certifications, or scalability options by navigating the links on the menu on the left side of the window.

In my last post I created a very simple ASP.NET MVC application that uses SQL Azure and Windows Azure AppFabric cache.  I would now like to take my application and deploy it to the Windows Azure AppFabric Application Manager.  To do so I have two options – publish from Visual Studio 2010 or upload the application via AppFabric Application Manager.  For the purposes of this initial walkthrough, I decided to use the AppFabric Application Manager.  I click on the “Upload New Package” link and am prompted for the path to the AppFabric package.  I figured the process to get the package would be similar to that of a standard Windows Azure application – from Visual Studio, right-click on my cloud project and select “Publish” and choose to not deploy but just create the package.  I would be wrong.  In the June CTP for AppFabric Applications, it doesn’t work like that (personally I hope this changes to be more like standard Azure apps).  I’ll need to get the path to the AppFabric package (an .afpkg file) from the build output window (or browse to the .\bin\Debug\Publish subdirectory of the application).

Now that I have the package, I can upload it via the AppFabric Application Manager. I’ll receive a nice progress dialog while the package is being uploaded.

Once uploaded, I received a dialog to let me know that I’ll soon be able to deploy the application.  This is somewhat similar to traditional Windows Azure applications – I first upload the package to Windows Azure and then I can start the role instances.

Note: While working in the AppFabric Manager I did notice there is no link back to the main portal.  I found that kind of “funny” since there was a link from the portal to the AppFabric Manager.  I opened a second browser tab so I could have the portal in one and the manager in another.

Now that my application is imported into the Windows Azure AppFabric Application Manager, I will need to deploy it.  I can see in the summary screen for my application the various aspects of my application.  In my case I can see the services (the AppFabric cache and SQL services) and endpoints (my ASP.NET MVC app endpoint).  I also notice the containers are listed as “Imported”.

In order to deploy my application, I simply click the “Deploy Application” link on the Summary screen. Doing so will bring up a dialog showing what will be deployed, along with an option to start the application, or not, after the application is deployed.

While deploying the application I noticed the State of each item under Containers update to “Deploying…”.  This process will take a few minutes to fully deploy.  The State changed from “Deploying” to “Stopped” to “Starting” and finally “Started”.

This process takes about 10 minutes to get up and running and usable.  Most of that time was spent waiting on DNS to update so that I could access the application.  It was about 4 minutes to go from “Deploying” to fully “Started”.

Now my application is up and running!  I didn’t have to mess with determining what size VMs I wanted, how many instances, or any “infrastructure” stuff like that.  I just needed to write my application, provide credentials for SQL Azure and AppFabric Cache, and deploy.  Pretty nice!  This is a very nice and easy way to deploy applications without having to worry about many of the underlying details.  Azure AppFabric Applications provide a whole new layer, and a good one in my opinion, of abstraction on the Windows Azure platform.  It may not be for every app, but I certainly feel is fits a good many applications.

UPDATE 7/13/2010: Corrected statement related to use of AppFabric CTP provided SQL Azure and storage accounts.


Creating My First Windows Azure AppFabric Application

Microsoft recently made available the Windows Azure AppFabric June CTP to get started developing Windows Azure AppFabric applications.  Read the announcement post from the AppFabric Team for a good overview of the Azure AppFabric application model.  Be sure to download the CTP SDK too.  You can also get a FREE 30-day Windows Azure pass at, using the promo code “MikeOnAzure”.

Once you have the SDK installed, you’ll want to get started creating your first Azure AppFabric application.  Launch Visual Studio 2010 and create a new project.  In the New Project Template wizard, you’ll see a new “AppFabric” section.  You might have expected the Azure AppFabric projects to be located under the “Cloud” area, as that is where the other Azure project templates are.  I did too.  My assumption here is that this is CTP and the location of the templates are likely to change before final, or that Microsoft is looking to further merge the AppFabric’s (Windows Server and Windows Azure), thus making the choice a deployment target and not a specific type of project.

For the purposes of this walk-through, I’m going to create a new “AppFabric Application”.  I’ll pick a cool name for my project and let Visual Studio create it.  This will create an empty AppFabric Application in which I can start to add my services/components.  There are a few oddities with the new project, and I will chalk this up to being an early CTP.  The first is that there is no visual indication that the project is an “AppFabric” application.  For instance, the project icon doesn’t contain the “AppFabric” icon overlay that is on the New Project template selection.  The second thing I find odd is the “App.cs” file.  At first glance, this looks like a regular C# file.  There’s no visual clue that it is a special type of file.  Double-clicking on the App.cs file will open the Design View for your AppFabric Application.

I can now add a new service by clicking on the “Add New Service” link/button in the upper-right corner of the Design View window.  In this case I’m going to add a new ASP.NET MVC2 project.  When that is done, the standard ASP.NET MVC2 project is added to the solution.  Since I’m adding this application as part of a Windows Azure AppFabric Application, Visual Studio automatically adds a few new assemblies related to hosting my web app in the AppFabric Container.  The new assemblies for the AppFabric Container are:

  • Microsoft.ApplicationServer.ApplicationModel
  • Microsoft.ApplicationServer.Web
  • Microsoft.ApplicationServer.Web.Hosting

The Design View will also update to reflect the addition of my new ASP.NET MVC2 application.  From there I can tell that my web app contains one endpoint and it does not reference any other services.

At this point I’m ready to go.  To see the basic setup, I select “Start without debugging” (or press CTRL + F5) from the Build menu.  There is no F5 debugging option in this CTP release.  Visual Studio will kick of the build and deployment process.  I can view the deployment output in the Output window.  Notice here that Visual Studio is starting a new emulator, the Windows Azure AppFabric Emulator.  Visual Studio will also start the standard Windows Azure compute and storage emulators.

From the Output window I can see the Application Id for your deployment.  Also of interest is the path to the various log files that are created as part of running in the Windows Azure AppFabric container.  It is my assumption that these log files would be similar to the logging available when running the application in a production Azure AppFabric container (upcoming post to walk-through that process).

Visual Studio will also launch a new console window that includes in the title the Application Id for your application.  This is the new emulator for Windows Azure AppFabric Applications.  Right now it’s pretty rough-looking – I’d expect it to get better before the final release.  I don’t see a whole lot here while the application is running.  I did notice the first time I started the application that the web browser (if creating a web application) will launch and Visual Studio will report the app is deployed and ready a little prematurely.  In that case, wait until the AppFabric Application emulator reports the app is ready and then refresh the browser.  I only noticed this on the initial deployment for the application – subsequent deployments seem to work as expected.


Now I would like to add a new SQL Azure “service” to my application.  Notice that the component is supposedly a SQL Azure service, yet the description indicates a SQL Server database (nearly any variant).  Possibly a CTP issue?

At this point Visual Studio will set up the SQL Azure information for me.  The design view will indicate a new SQL Azure instance is available, and viewing the Properties will allow me to set the database name, connection string, and actions to take against the database upon deployment and tear down of the application.  I did notice the provisioning process did not create the database for me as I would have expected.  (UPDATE: Learned from Neil MacKenzie’s recent post that the SQL actions to provision and de-provision apply only if using a DAC pack.)  Also, the default setup is to use SQL Express, not SQL Azure.  Although changing to be SQL Azure should be a simple connection string change.

Now I need to wire up the connection between my web app and the database.  To do so, simply add the SQL service as a Service Reference.

At this point, I can easily add some code to query my newly created database (note that I created a database manually and configured the connection details in the Properties panel). 

using (SqlConnection sqlConnection = ServiceReferences.CreateSQLAzureImport())
 var cmd = sqlConnection.CreateCommand();
 cmd.CommandText = “SELECT top 1 ProjectName FROM Project”;
 cmd.CommandType = CommandType.Text;
 result = (string)cmd.ExecuteScalar();

At this point I can press CTRL+F5 to run my application.  I expected my home page to show some data from my SQL connection.  Instead, I was greeted with an error message stating that I didn’t have permissions to access the database.  That’s odd . . . I’m an admin on the machine!

Applications running in the AppFabric container run under the NT AUTHORITY\NETWORK SERVICE security context, and as such don’t have many rights.  I changed the SQL connection string from the default Integrated Security to instead use SQL authentication (by setting User ID and Password properties).

To complete my fun little app, I decided to add a reference to Windows Azure AppFabric Cache to cache data instead of hitting the SQL Azure database each time.  To use it simply entered my cache authorization token and cache service URL in the service properties panel.

The code to work with AF Cache in an AF Application is pretty darn easy.

DataCache cache = ServiceReferences.CreateDataCacheImport();
time = cache.Get(“time”) as DateTime?;
if (time == null)
      time = DateTime.UtcNow;
      cache.Add(“time”, time, TimeSpan.FromMinutes(5));

When done, the deployment diagram for my simple app looks like this:

Overall, I’m pretty happy with this first CTP of the Windows Azure AppFabric Application SDK.  It has it’s rough edges, but it’s pretty nice overall.  I can definitely see the value-add and the direction looks really good.  Exciting!!

In an upcoming post I’ll walk through the process of deploying this application to the Windows Azure AppFabric container.

Windows Azure AppFabric Caching Service – It’s Alive!!

The Windows Azure AppFabric Caching Service was released yesterday as a production service.  Previously this service has been available as a CTP service only.  I’m thrilled to see this service being made available now as a production level service.  I think the caching service is a huge feature for those doing scalable, robust services on the Windows Azure platform.  No longer do you need to implement your own “caching service invented here” solution, or go through the steps to implement another caching solution for your Windows Azure hosted solutions.

As a CTP service, Windows Azure AppFabric Caching was free.  Now that as a production service you would expect that to change, right?  Not so fast my friend!  The service is being made available for free until August 1, 2011.  After the free promo period ends in August, pricing for the service will vary based on the size of the cache you request – ranging from $45/month for a 128 MB cache to $325/month for a 4GB cache.  Be sure to check your platform offer as you might be able to get some caching for free as part of the offer.

Unfortunelty I haven’t had a chance to really dive into the caching service much yet.  I’m hopeful I will soon though.  When I do, I’ll be sure to post any tips/tricks or thoughts here.  In the meantime, here are a few good places to go to help get you started with the Windows Azure AppFabric Caching Service.

Need a Windows Azure account to help get you started?  Click on the nice blue Windows Azure Pass banner on the right of my blog and use promo code “MikeOnAzure” (or navigate your way to and still use “MikeOnAzure” for the promo code).