Windows Azure Developer Camps

Microsoft and Catapult Systems will be hosting two Windows Azure Developer Camps in Tampa, FL on 5/22 and Atlanta, GA on 5/29. I’ll have the honor of being the instructor at both events.  This is a free, one-day Windows Azure Instructor lead Workshop where you roll up your sleeves and get hands-on with the latest Windows Azure development tools and technologies.

During this full day of hands-on training you’ll learn how to:

  1. Deploy Cloud Services in Windows Azure with Visual Studio
  2. Connect your existing applications & data to an IaaS Application with a Virtual Network in Windows Azure
  3. Build Windows Store Apps with Windows Azure Mobile Services

If you plan to attend one of these events, or if you are just curious to see what Azure can offer, sign up for a free 90-day Azure trial. If you are a student, you should also sign up for Dreamspark, which includes a free Windows Store developer license. (You need the Windows Store developer license to send push notifications to a Windows 8 client.)






Pluralsight was kind enough to provide an Annual subscription to their online developer training library of over 450 video courses, a $299 value, as a raffle prize.









Telerik has also provided a DevCraft Complete license, a $1,499 value, for the raffle!

*Please note that you must be present to win

MSDN 6 Part FREE Webcast: Cloud Computing Soup to Nuts

Microsoft MSDN Webcast has begun a Level 100 6 Part Series on Getting Started with Windows Azure


Part 1: 2/7/2012 11:00 am PST Get Started with Cloud Computing and Windows Azure

Get started with Windows Azure and cloud computing. Explore what Windows Azure is and isn’t and get started by building our first cloud application.


Part 2: 2/14/2012 9:00 am PST Working with Windows Azure Roles

Take a look at how roles define what a service is. Beyond the different flavors of roles we show the RoleEntryPoint interface, and how we can plug code in the startup operations to make it easy to scale up instances. We will show how the Service Definition defines the role and provides hooks for customizing it to run the way we need it to.


Part 3: 2/21/2012 11:00 am PST Windows Azure Storage Options

In this webcast we look at Windows Azure Storage and explore how to use the various types available to us including Blobs, Tables and Queues

Part 4: 2/28/2012 11:00 am PST Introduction to SQL Azure

Dive into SQL Azure and see how it is similar and different from on-premise SQL Server. From connecting from rich client as well as web apps to the management tools available for creating schema and moving data between instances in the cloud and on site we show you how it’s done

Part 5: 3/6/2012 11:00 am PST Access Control Services and Cloud Identity

Access Control Services is a modern identity selector service that makes it easy to work with existing islands of identity such as Facebook, Yahoo and Google.


Part 6: 3/13/2012 11:00 am PST Diagnostics and Troubleshooting

This weeks webcast is focused on looking at the options available for gaining insight to be able to find and solve problems. From working with Intellitrace to capture a run history to profiling options to configuring the diagnostics agent we will show you how to diagnose and troubleshoot your application.

Why So Many Azure Storage Transactions?


Y U NO Azure StorageRecently, I had a client sign up for a Windows Azure account getting the first 90 days for free. This free account gives you a 1GB SQL Azure Web edition database, 50,000 storage transactions and 750 small compute hours.  This should be plenty for the next couple of months, or so I thought. 

This is a simple application that uses a small SQL Azure database and Blob Storage for uploaded images. After the Azure account was provisioned, I created the Hosted Service, Storage Account, SQL server and the publish Certificate.  Then I updated Visual Studio and deployed the application to Azure. The initial testing went great, uploaded a few images, ran a few queries, no problems at all.

The next morning the site is down. So I logged into the management portal and discovered that the account had been suspended due to exceeding the constraints of the free account.  Well, It’s nice that instead of ending up with a large bill at the end of the month you can set spending limits and have your account suspended when that amount is exceeded. In this case, the spending limit defaulted to $0.00 for the first 90 days. The new Azure billing portal is quite helpful and shows exactly what happened. I exceeded the 50,000 storage transactions limit IN ONE DAY! The only thing I use storage for is uploaded images.  How could I have used that many reads, writes and deletes in one day. Well, it turns out I didn’t.




The first issue I noticed was the error log showing that the google and bing bots could not locate the robots.txt file. Of course…it’s a new site and these bots are crawling all over it attempting to index the pages. So I added a robots.txt to prevent image bots from indexing the images.


User-agent: Googlebot-Image
Disallow: /

User-agent: MSNBot-Media
Disallow: /

This helped a little but I was still getting 60,000+ storage transactions a day.  So I submitted Windows Azure Incident ticket explaining my problem.



A few hours later I received an email from the Windows Azure Help Desk


To: Randy Patterson

Cc: MSSolve Case Email

Subject: RE: Callback:why 100,000 storage transactions a day

Hi Randy

After looking at the logs It looks like WAD logging is enabled in your deployment and this will use at least 25 trx/min

Please check if this is enabled in your deployment. If so you will have to uncheck enable diagnostics to avoid the transactions.

Star Trek double face palmStarting with version 1.6 of the Azure SDK, Diagnostics is enabled by default. According to the email, diagnostics activity will generate a minimum of 36,000 transactions per day! I was experiencing closer to 60,000/day. This will exceed the 50,000 transaction limit in 1-2 days.

To Disable Diagnostics: In the solution explorer, double click on the web role configuration file and uncheck both "Enable Diagnostics" and "Use publish Storage Account"


**Updated 2/2 to include disabling IntelliTrace

IntelliTrace And Profiling

After a few days of monitoring the account I was STILL getting tens of thousands of transactions each day.  Another Azure support ticket discovered that this time I had enabled IntelliTrace without realizing it.  When you publish make sure you disable both IntelliTrace and Profiling.


Debugging a Published Hosted Service with IntelliTrace and Visual Studio

Now I am being billed for a few hundred transactions each day instead a 100,000.  Storage transactions are cheap, but it will cause a free trail account to get suspend in just a few days.



  1. Make sure you have a valid robots.txt file for your site.
  2. Disable Diagnostics – enabled by default
  3. Disable Intellitrace – Visual Studio Ultimate Version only
  4. Disable Profiling

Hopefully, this will help you get the most out of the Windows Azure Free Account.


EF Code First DB Initialization Using Web.Config

The DBContext used by Entity Framework Code First allows you to set a strategy for how your database is updated when your application starts.  While this is a huge time saver for development it is usually not something you want to allow for production.  The last thing we need is to deploy an update to production and have the application drop and recreate the production database.

The following database initialization options are available:

  • DropCreateDatabaseIfModelChanges – This strategy recreates your database only if the Entity Framework model is different from the database or the database does not exist. This is the most common strategy used while developing
  • CreateDatabaseIfNotExists (Default) - If no database is found it will be created according to your Entity Framework Model.
  • DropCreateDatabaseAlways - This strategy always drops the database and recreates it. This is helpful for integration and database test projects where a fresh database with deterministic data is created for each test.
  • Custom – Used to Implement your own strategies or add seed and test data to an existing strategy. This post shows an example of extending the strategy DropCreateDatabaseIfModelChanges and seeding the new database with test data
  • null – Disables the EF Code First Initialization process

Given the following model and context:

public class Wizard
	public virtual int WizardId { get; set; }
	public virtual string Name { get; set; }
	public virtual int Level { get; set; }
	public virtual ICollection<spell> Spells { get; set; }

public class Spell
	public virtual int SpellId { get; set; }
	public virtual string Name { get; set; }
	public virtual int LevelRequired { get; set; }

public class FantasyContext : DbContext
	public DbSet<wizard> Wizards { get; set; }
	public DbSet<spell> Spells { get; set; }

We can create a Database Initializer strategy that will drop and recreate the database seeding it with test data whenever the model changes.

public class FantasyContextInitializer
	: DropCreateDatabaseIfModelChanges<FantasyContext>
	protected override void Seed(FantasyContext context)
		var Gandalf = new Wizard
			Name = "Gandalf the White",
			Level = 100,
			Spells = new[]
				new Spell { Name = "Illumination", LevelRequired = 10 },
				new Spell { Name = "Sword of Power", LevelRequired = 50 },
				new Spell { Name = "Lightning Strike", LevelRequired = 60 }
		var Merlin = new Wizard
			Name = "Merlin",
			Level = 100,
			Spells = new[]
				new Spell { Name = "Magical Kinesis", LevelRequired = 10 },
				new Spell { Name = "Blinding Light", LevelRequired = 50 },
				new Spell { Name = "Destructive Blast", LevelRequired = 60 }

The canonical example for adding this strategy to the DbContext is by adding a single line to the Global.asax Application_Start method.

protected void Application_Start()
	Database.SetInitializer(new FantasyContextInitializer());
	// Other startup stuff goes here

However, this makes it difficult to remove the initializer for release builds or to define a different strategy for Integration Tests. Fortunately, you can define the DbContext Initializers in the config file and change or remove them using XLST transformations (For an excellent primer on Web and App config file transformations see Oleg Sych’s article Here).

To use the web.config you must first remove the SetInitializer line from the Application_Start method. Then add the following section in your web.config file.

	<add key="DatabaseInitializerForType Wizards.Models.FantasyContext, Wizards"
	         value="Wizards.Models.FantasyContextInitializer, Wizards" />
	<!-- Other stuff here -->

The key starts with DatabaseInitializerForType and includes the fully qualified assembly name for your Context object. The value is the fully qualified assembly name for the initialization strategy object, FantasyContextInitializer in the example. The next step is to add a transformation to the

image Web.Release.config file to remove the initializer when we publish a release build. If you do not have a Web.Release.config file in your project then right click on the web.config file and choose Add Config Transformations. This will add a configuration file transformation for each build type in your solution.  For example, the default debug and release builds will result in a Web.Debug.config and Web.Release.config files added to your solution.

Adding  the following lines to your Release config file will remove the Database Initializer from the web.config

    <add xdt:transform="Remove"
         xdt:locator="XPath(//add[starts-with(@key, 'DatabaseInitializerForType')])" />

This transformation states: Within the appsettings section locate an add element that has a key attribute that starts with DatabaseInitializerForType and remove it.



XML Transformations can be a bit tricky at first to setup but, once mastered, can be a powerful tool for setting up your different environments.



ReSharper and the Method Group Refactor

While writing code similar to the following lines, ReSharper suggested the “Replace With Method Group” Refactoring for Line 2.
   1: var names = Directory.GetFiles(@"c:\Program Files").ToList();

   2: names.ForEach(n => Console.WriteLine(n));

The Method Group shorthand is usually found in places where you take the following code

myButton.Click += new EventHandler(myButton_Click);

and replace it with this.

myButton.Click += myButton_Click;

The C# compiler can infer the usage of the EventHandler class, giving you cleaner, less noisy code.

Letting Resharper apply the Method Group refactoring produces the following code.
   1: var names = Directory.GetFiles(@"c:\ProgramFiles").ToList();

   2: names.ForEach(Console.WriteLine);

I was pleasantly surprised by the results. Apparently, I don’t have to explicitly declare the intermediate lambda variable ‘n’ just so I can pass it into the WriteLine method. The compiler is smart enough to infer this for me.  Although a little confusing at first, this shorthand notation is pretty nice.  I doubt I would have realized this without ReSharpers’ refactoring suggestions, one of the many reasons I’m a R# Junkie.

Moved my Blog

Moved my blog to a new server to support the latest ASP stack.  Also took the time to upgrade the software from an old version of dasBlog to WordPress, very happy with WordPress so far. Had to write a simple redirector to redirect the old permalinks to the new WordPress links.

Please be patient as I update the formatting of previous posts.

Installing VS 2010 in XP Mode

Although installing Visual Studio 2010 B2 and 2008 on the same machine is supported, Microsoft does NOT recommend installing beta software of your development machine. Installing Visual Studio 2010 beta in a Virtual environment is highly recommended but it does, however, have some drawbacks. Fortunately, with Windows 7 there is a hybrid approach that allows you to install VS 2010 on a virtual operating system but interact with it as though it were running on your host machine.

What you need:

  1. Windows 7 Professional or higher for the host machine
  2. Windows XP Mode and Windows Virtual PC ( download here)
  3. An operating System supported by VS2010 for your Virtual environment
    • While XP Mode comes with an XP Image already setup you can use just about any MS Operating system.  I chose to use Windows 7 instead of XP
  4. Visual Studio 2010 Beta 2 can be downloaded here.

Installing Visual Studio

Once XP Mode and Virtual PC are installed the next step is to install a virtual OS to host Visual Studio 2010. You can find instructions for this here. It is very important that the user you created for your virtual machine has a password.  Integration Services cannot be enabled without a password and no error message is displayed.

“By enabling ClearText in your Virtual Machine, text in Visual Studio will look much better when viewed in XP mode.”

Next, while the virtual machine is not running go to the settings dialog

VPC Settings Image

Make sure “Automatically Publish” is checked. This will allow applications that are installed to automatically show up in your host’s start menu.   


Start the Virtual Machine and Enable Integration Services.  You’ll be prompted for a user name and password, use the same credentials you used to log into the virtual machine.


Finally, install Visual Studio 2010 B2 on the virtual machine. (this may take awhile)  After you’ve finished shut down the Virtual machine.

Setup Host Machine

Back on your Windows 7 host you will now have Visual Studio 2010 on your start menu.  In my case I called the Virtual Machine VS2010B2 so visual studio 2010 can be found at start-> Windows Virtual PC –> VS2010B2 Applications –> Microsoft Visual Studio 2010


Clicking on VS2010 will first start the Virtual Machine.  If you are prompted for credentials use the same administrator login and password you used to setup the VM.


After a few moments, Visual Studio 2010 will appear on your desktop.  Any application on your desktop that is running in a VM will have (Remote) appended to the title in the task bar. 


The integration is so complete even the ASP.NET Development Server and Internet Explorer bleed through to your desktop.


TFS Basic Version


Team Foundation Server 2010 Beta 2 has a new Basic version targeted for smaller shops.  According to Brian Harry’s Blog, this new version will be “as cost effective” as SourceSafe.   Not sure what “as cost effective” means but lacking any specifics I think it’s safe to assume that it will be much cheaper.  TFS Basic version is targeted for small shops but includes a large number of features. So what does it give you and, more importantly, what does it lack.




  1. Can use SQL Express or an existing SQL Server Instance
  2. Can be installed on Server AND Client Operating Systems including Vista and Widows 7 (32 & 64 bit versions).  Brian successfully tested the installation on a netbook!
  3. You get Version Control (of course)
  4. You get Bug Tracking (no mention of other work item types)
  5. You get Automated Builds!  (Continuous Integration!)
  6. As your needs grow, you can reconfigure TFS Basic to include more features.


  1. Lacks Sharepoint Portal
  2. Lacks Reporting Services



While the Portal and Reports are nice, for a small shop they are not that valuable. My experience has been that even large shops tend to ignore these features.  I am looking forward to getting my hands on this version and seeing first had what it can do.


Windows Azure Commercial Release this year!


After conferring with several Microsoft Windows Azure Speakers and Azure Project Managers at TechEd last week, I was able to ferret out a tentative release schedule for Windows Azure.

  • Azure Platform and Services – Commercial Release on track for PDC this year (Nov 2009)
  • Visual Studio 2010 – On track to be released at PDC this year.  (Nov 2009)
  • Window Azure pricing and Service Level Agreements on track for a July 2009 announcement.
  • SQL Server Data Services Relational Data  – Beta this summer, release expected by the end of 2009.
  • Visual Studio 2010 Public Beta – Available in the next couple of weeks.

This is good news.  In just a couple of months we’ll have a good idea of what “Cloud Services” will cost and this will determine it’s viability for Small, Medium and Enterprise customers.  Without this information, it becomes impossible to plan ahead or convince potential customers to invest in Cloud Services development.   Also,  with a release date in sight and, hopefully, a stabilization of features, we can focus the the potential uses for this new technology instead of looking into the ever changing feature list.

Keep in mind that these dates are speculative and may change depending on bug feedback to Microsoft.  However,  each Speaker or Project Manager that would give me a timeline stated that Azure and VS 2010 was on track for release around PDC this year.

Orlando Code Camp 2009 – Unity Presentation Slides and Code


With over 500 attendees and 11 tracks to choose from, the Orlando Code Camp was once again a huge success!   Congratulations to all of the volunteers that helped organize this event.

I gave a presentation on an introduction to the Unity Application Block – Understanding Inversion of Control and Dependency Inversion Principles by introducing the Unity Application Block into an existing application.  You can download my presentation slides and code samples here


I enjoyed meeting everyone in Orlando,  hope to see you next year.

Randy Patterson