Friday, 9 December 2011

The only Windows Azure Pricing Calculator you will ever need

I wrote this to cost up a project:

For UK currency.

Unlike every single other calculator out there it allows you to…

  • Specify a profile for 5 environments (each profile can differ in number/size of Compute Instances etc):
    • Integration Test
    • System Test
    • User Acceptance Test
    • Pre-Production
    • Production
  • Specify how many hours (per week) you need your Compute Instances for (you might be happy to tear down your hosted services each night – if you’re not using them, why pay?)

Monthly and yearly totals shown.

Friday, 4 November 2011

Windows Azure Pricing

Pay as you go:

What qualifies as a transaction in Windows Azure Storage (you pay per transaction):

MSDN Benefits for Windows Azure:

Thursday, 3 November 2011

Windows Azure and operational cost reduction

One of the things that strikes me the most about using Windows Azure (or most cloud solutions) is the savings you can make with your test environments.

In Windows Azure world, your on-going cost is for your Compute instances (what you deploy your applications to) and your storage. Whether you are using the application or not, you are paying money for your Compute instances and storage to exist. Other costs (Access Control, CDN etc) you pay per use or transaction.

So if you have a system test or user acceptance test environment that you are not using, you can simply delete the Compute instances and any storage artefacts. Then you don’t pay for them.

Contrast this will your on premise applications. You probably have multiple test environments for different projects and those are sitting there, costing you money whether you use them or not.

Some people suggest that Windows Azure (and some other cloud services are not that cheap). I disagree. Let’s say I need a system test environment for 5 days a month. A “Large” Compute instance (4 x 1.6GHz, 7GB RAM, 1000GB storage) costs $0.48/hour. Well 5 days at 8 hours a day (most people don’t work 24/7) costs me $19.20 (this includes the operating system license). I can script the creation of my compute instances and other artefacts very simply, so automatically spinning up or shutting down assets on demand.

So, a pretty meaty server for a system test environment on Windows Azure costs me $19.20 for the 5 days per month I want to use it.

How much is your on premise hardware costing to run for a whole month?

Tuesday, 1 November 2011

PowerShell, MSBuild and 64-bit platforms

If you call PowerShell from MSBuild on a 64-bit platform, you will often get unexpected errors. One such error is as follows:

No snap-ins have been registered for windows powershell version 2

The probable cause is that the MSBuild executable you are running is not 64-bit. On 64-bit platforms you should execute MSBuild from the following location:


Depending on how/what you have installed, your Start Menu shortcuts might be pointing to the 32-bit version.

Monday, 31 October 2011

Elegantly testing for a PowerShell Snap-In

This PowerShell script tries to load the WAPPSCmdlets snap-in, fails silently if the loading of the snap-in fails (if it isn’t installed), advises the user and exits from the script.

if ((Get-PSSnapin | ?{$_.Name -eq "WAPPSCmdlets"}) -eq $null)
  Add-PSSnapin WAPPSCmdlets -erroraction SilentlyContinue
  $SnapIn = GET-PSSnapIn WAPPSCmdlets -erroraction SilentlyContinue
  if ($SnapIn -eq $null)
    Write-Error "To run this script the 'Windows Azure Platform PowerShell Cmdlets' are required."
    Write-Error "Please download from '' and install as a PowerShell Snap-in (not as a Module)."

I’m testing for “WAPPSCmdlets” but you could test for any PowerShell Snap-in.

Simples (if you don’t get it).

Saturday, 22 October 2011

Increasing quotas on Windows Azure

By default, your subscription quotas on Windows Azure are as follows:

  • Cores – 20
  • Hosted Services – 6
  • Storage – 5

To increase these you need to submit a request:


  • Support topic – “Service Deployment and Developer Portal”
  • Sub-topic – “Quota increase”

Thursday, 29 September 2011

Error messages

This is a new one.


If you see the monkeys, let me know.

Wednesday, 28 September 2011

Assembly versioning (for .NET)

Like most people, I version my assemblies during the continuous integration build. This is achieved by generating a class file (I call it “AssemblyInfoCommon.cs”) during the build. It looks like this:

using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

[assembly: AssemblyCompany("Acme")]
[assembly: AssemblyConfiguration(" Debug")]
[assembly: AssemblyCopyright("Copyright © Acme 2011")]
[assembly: AssemblyFileVersion("")]
[assembly: AssemblyInformationalVersion("")]
[assembly: AssemblyProduct("PetShop")]
[assembly: AssemblyTrademark("Acme")]
[assembly: AssemblyVersion("")]


  • “” is the version number (we’ll come to the “xxx” value later")

  • The “AssemblyConfiguration” attribute breaks down as follows:

    • “Branch” is constant.

    • “Release” will vary depending on what you call your branches

    • “Debug” is the Visual Studio Solution configuration so will typically be “Debug” as shown or “Release”.

  • The company name, copyright notice and year all all passed in from the build script as variables.

  • The product name is whatever the project is called.

This is all pretty straight forward so far. However, down the years I’ve had problems with a strategy for the version number.

In the .NET world, the version number breaks down as follows:



Originally, the my version numbers broke down as follows:


Where “major” and “minor” are configured manually (these never automatically increment).

The “revision” number breaks down as follows:

  • “y” is the last digit of the current year. For 2011, this is “1”.

  • “MM” is obviously the month.

  • “yy” like wise for the day.

The “build” number represents the number of builds today, so the first build of the day takes “1”, the second “2” etc.

The would give you the following build numbers (I’m choosing old dates for a reason…):

  • 1.0.10926.1 – the first build on 26th September 2001

  • 1.0.11231.3 – the third build on 31st December 2001

  • 1.0.20101.4 – the fourth build on 1st January 2002

This worked pretty well for a number of years. Unfortunately, there is a constraint on the components of the version number that did not become apparent until 1st January 2006.

The first build number for 1st January 2007 was (in theory) “x.y.70101.0”. Unfortunately each component of the version number is an “Int32”. The largest value for an Int32 is “65534”, “70101” is bigger than this. Queue me getting build failure notification e-mails while on a beach in Thailand on New Year’s day, which was nice.

Since then, I’ve wrestled with a couple of different strategies but none ever really worked. The one I got most mileage out of was the same as before for Major, Minor and Build but had a different strategy for the Revision. I used the day of the year in combination with the year. So the Revision for…

  • 31st January 2011 would be “1031” (the 31st day of the year)

  • 2nd February 2011 would be “1032” (the 32nd day of the year)

  • 31st December 2011 would be “1365” (the 365th day of the year)

  • 1st January 2012 would be “2001” (the 1st day of the year)

This is problematic for two reasons:

  • You have to do maths to work out when a version was built.

  • Years ending in 0 (2010, 2020) cause problems because of leading zeros get dropped by the compiler. So 1.0.0001.0 (1st Jan 2010) would become which is confusing.

Recently I’ve found a new strategy which works pretty well. The problem with the first strategy is fitting revision numbers for “high” years into an Int32, the problem with the second one is leading zeros. This third strategy overcomes this and breaks down as follows:


Where “major” and “minor” are as before.

The “revision” number breaks down as follows:

  • “yy” is the current year. For 2011, this is “11”.

  • “MM” is again the month.

The “build” number is as follows:

  • “dd” is the day.

  • “xx” is the build number of the day.


  • 1.0.1109.2601 = 26/09/2011, 1st build of the day

  • 1.0.9912.3199 = 31/12/2099, 99th build of the day

  • 1.0.1201.0101 = 01/01/2012, 1st build of the day

  • 1.0.1112.3199 = 31/12/2011, 99th build of the day

There’s one caveat – best to not have more than 99 builds in one day but that is a highly unlikely scenario.

Tuesday, 27 September 2011

BizTalk Message Box Viewer

The “BizTalk Message Box Viewer” is a nifty little tool that complements the BizTalk Best Practices Analyser very well:

Monday, 26 September 2011

BizTalk Best Practices Analyser (1)

Two issues that are easy to fix.

Details for both here:


Thread Pool Setting of Host Instance MyHostInstance of Host MyHost

You need to change the registry settings. A example registry file (.reg) is as follows:


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\BTSSvc$MyHost\CLR Hosting]


You will need to change “MyHost” to match your host name. If you create a .reg file with this content, you can easily merge it to your registry.

The “dword” values are as follows:

  • Max IO threads = 100
  • Max worker threads = 100
  • Min IO threads = 25
  • Min worker threads = 25

These values are taken from the MSDN link above.


No maxconnection Setting is Found in machine.config or BTSNTSvc.exe.config or BTSNTSvc64.exe.config

You need to change the following files:

  • %systemdrive%\Program Files (x86)\Microsoft BizTalk Server 2009\BTSNTSvc.exe.config
  • %systemdrive%\Program Files (x86)\Microsoft BizTalk Server 2009\BTSNTSvc64.exe.config

Add a “” section as follows (by default, BTSNTSvc.exe.config and BTSNTSvc64.exe.config do not have such a section).

    <add address="*" maxconnection="12" />

Where the “maxconnection” value should be 12 multiplied by the number of processors on the server. The above is an example only, in my scenario each BizTalk server had two processors, so my “maxconnection” value was “24”.

Friday, 23 September 2011

Cloud outages

A letter in The Economist earlier in the year puts an interesting perspective on cloud outages.

SIR – I was disappointed that your article added to the hysteria that surrounds cloud computing (“Break-ins and breakdowns”, April 30th). In my view cloud computing is like commercial aviation. Which is safer per-mile of travel: aircraft or automobile? Car crashes are responsible for more deaths, yet a plane crash is certain to make the news. For the same reason, cloud computing outages are considered newsworthy. Although the frequent down times of companies’ internal IT systems are less publicised, these down times almost certainly cause more harm and lost productivity in aggregate (like car accidents).

Air travel makes people uncomfortable, in part because of a loss of control, no matter how well trained and experienced the pilot may be. Similarly organisations fear cloud computing, preferring to be “behind the wheel”. Yet transportation statistics show that desire can be misguided.

Aviation had its share of hype and detractors, but no one would argue that it has not transformed travel. I predict that once the dust settles, cloud computing will be no less transformative.

Milo M.K. Martin
Associate professor of computer science
University of Pennsylvania

Tuesday, 20 September 2011

How we see each other

I don’t know where this came from so I can’t credit it but many props to the original author, who ever you are.


Monday, 19 September 2011

Connecting to TFS Preview from Visual Studio 2010

Took me a few minutes to figure out why I was getting an error connecting to TFS Preview.

First (and most obviously) you need Visual Studio 2010 with SP1 applied. You should have SP1 by now anyway.

Secondly (and less obviously) you need to install KB2581206.

There is a link to “download software” on your TFS Preview Admin page which lists all this but it’s easy to miss the link to KB2581206.

When you have the hotfix installed, connecting is just the same as normal. From the “Add Team Foundation Server” dialogue in VS2010:

  • Name or URL of Team Foundation Server = [your account name]
  • Connection Details:
    • Path = tfs
    • Port = 443
    • Protocol = HTTPS

You authenticate with a web identity provider e.g. Windows Live ID.

While its in preview, this hosted TFS solution is in Microsoft’s Chicago data centre. Even though it’s a hosted solution, you can still have your own TFS Build Agents.

Tuesday, 13 September 2011

Windows 8

This poses a tricky question, though. You see, not only does IE10 power Windows 8′s primary interface, but Internet Explorer 10 — the browser — is also available as a Metro-style app, and as a full-interface browser in the Explorer Desktop. All three versions are fundamentally identical. Now… what if Windows 8 is as successful as Windows 7 and all of its previous forebears? What if Windows 8 is actually a success on the tablet? If Windows 8 becomes ubiquitous, so does Internet Explorer 10 — and if IE10 can be found on hundreds of millions of devices, what platform do you think developers will choose?

It’s the great Web App Dream: write once, run anywhere. Do you write an app for tens of millions of iPhones and iPads, or do you write a single piece of HTML, CSS, and JavaScript that can run perfectly on every Windows 8, IE10-powered tablet, laptop, and desktop? Those same web apps, with a little tweaking, will probably even work with Chrome and Firefox and Safari — but here’s an uncomfortable truth: if Windows 8 reaches 90% penetration of the computing market, why bother targeting a web browser at all? Just write a native, Metro-style web app instead.

Finally, add in the fact that IE10 will almost certainly come to Windows Phone 8 next year, and you will have a single app container — AppX — that runs across every damn computer form factor.

Microsoft, threatened by the idea of OS-agnostic web apps and browser-based operating systems from Google and Mozilla, has just taken the game to a whole new level — and, rather shockingly, given that Windows 8 started its development in mid-2009, it would seem that the lumbering behemoth might have actually out-maneuvered Google.”


Monday, 15 August 2011

Castle Windsor 3.0 beta

Castle Windsor 3.0 beta is available:

There are numerous new features, one of the more interesting ones is that the WCF Integration Facility is now officially part of the release:

Google buys Motorola Mobility

Google has bought Motorola Mobility, the mobile part of Motorola spun off as a separate entity a few years ago.

This makes for an interesting story with respect to Google’s Android partners, HTC, Samsung and around 30 others. Google is now competing against those companies. Will they now focus on another platform where they don’t have to compete with the vendor? Windows 7, say?

Friday, 5 August 2011

String Comparison in .NET

Hate stuff like this:

if (myValue == "true")

Like this:

int compareResult = string.Compare(myValue, true.ToString(), StringComparison.OrdinalIgnoreCase);

Two things.

  1. Explicit control over casing, nothing is assumed.
  2. No magic hard coded string i.e. true.ToString() versus “true”.

Note that true.ToString() is actually “True”.

Wednesday, 3 August 2011

Finding duplicate SPNs

You can’t have duplicate Service Principal Names (SPNs), its just not allowed. An SPN with a duplicate will not work. To find all duplicate SPNs in your domain, simply run the following:

setspn.exe –x

And that is it.

Tuesday, 2 August 2011

ThoughtWorks Technology Radar July 2011


Continuous delivery
Maximise automation including “infrastructure as code” (see below), environment management and deployment automation. This is about taking control of your deployment process, reducing time the taken to get changes into production from weeks or months to days (or less). This is different from the recent concept of “continuous deployment” which is about putting every change into production (though while different, continuous delivery and continuous deployment dovetail well).

Infrastructure as code
Treat your infrastructure configuration the same as you would treat source code – source control, versioning, push out changes to the data centre in an automated manner.

Fostering collaboration between your development and operations teams.

Now a viable alternative to native applications and is cross platform.

Stored Procedures
I will quote directly:

It is startling to us that we continue to find new systems in 2011 that implement significant business logic in stored procedures. Programming languages commonly used to implement stored procedures lack expressiveness, are difficult to test, and discourage clean modular design. You should only consider stored procedures executing within the database engine in exceptional circumstances, where there is a proven performance issue.

So stored procedures are almost always bad.

Friday, 8 July 2011


Someone else agrees with me that getting rid of ACID is a bad idea. Enter “NewSQL”.

Tuesday, 7 June 2011

Microsoft Web Platform Installer

I have to admit at being very sceptical about the Microsoft Web Platform Installer, thinking it was just for noobs. Recently, I was nudged down the path of using it (to get the Windows Azure Tools) and I have to say it works very well. Rather than fishing around for various installers, you just pick what you want from the lists (see below) and the Web Platform Installer will go away and install everything for you. There’s no need to mess around downloading MSIs yourself.


The Web Platform Installer offers a comprehensive list of developer frameworks, servers and tools. In addition, it offers various products such as DotNetNuke, WordPress, Umbraco CMS, ScrewTurn Wiki, N2 CMS etc.

The Web Platform Installer has a tiny footprint too.

Great stuff.

Monday, 6 June 2011

Using the cloud to crack passwords?

There’s been much talk recently of using the processing power of the cloud, perhaps Amazon EC2 spot instances, to crack passwords.

Why bother? A cheap local GPU will do the job.

Password Time to crack  
fjR8n 24 seconds <1 second
pYDbL6 1 hour 30 minutes 4 seconds
fh0GH5h ~4 days 17 minutes 30 seconds

Seven character passwords are pretty common. Mixing upper case letters and numbers doesn’t really help.

Friday, 3 June 2011

Windows 8

The world changes. Here’s the best analysis I’ve read.

“…So if you're running an existing PC hardware or software company, ask yourself how a new competitor could use the platform transition to challenge your current products.  Here's a sobering thought to keep you awake tonight: the odds are that the challengers will win.  The company most at risk from this change is the largest vendor of Windows apps, Microsoft itself.  Microsoft Office must be completely rethought for the new paradigm.  You have about 18 months, guys.  Good luck.

By the way, web companies are also at risk.  Your web apps are designed for a browser-centric, mouse-driven user experience.  What happens to your app when the browser melts into the OS, and the UI is driven by touch?  If you think this change doesn't affect you, I have an old copy of WordStar that you can play with.  Google and Facebook, I am talking to you.

If you're running a hardware company, how will you need to change your devices to take advantage of the new OS?  Shipping a device that isn't Windows 8 ready will soon be as risky as shipping a PC in 1993 that couldn't connect a mouse.  (Unfortunately, because Windows 8 is so far out, I don't know if Microsoft has even fully defined the hardware spec for a Windows 8 PC.  The OS cries out for a flat panel screen that docks, so you can use it on your lap or as a monitor. Microsoft has a lot of work to do, and the PC vendors will face a lot of uncertainty.)…


Some people aren’t happy. Get a grip.

Sunday, 20 March 2011

SQL Server Service Broker simple example

I had a reason to use SQL Server Service Broker (SSSB) again recently. It’s a queuing mechanism built into SQL Server (from SQL Server 2005). It’s a great solution for providing messaging integration patterns with legacy databases.

It’s been a while since I used it and getting it working is a bit tricky the first time (or when you’ve forgotten the details). A very simple example to set-up SSSB is as follows:


USE [YourDatabase]



CREATE CONTRACT [YourMessageContract] ([YourMessage] SENT BY ANY );



CREATE SERVICE [YourMessageSendingService] ON QUEUE [dbo].[YourMessageSendingQueue]([YourMessageContract]);

CREATE SERVICE [YourMessageReceivingService] ON QUEUE [dbo].[YourMessageReceivingQueue]([YourMessageContract]);

DECLARE @Message xml
SET @Message= '<MyMessage>blah</MyMessage>'
DECLARE @handle uniqueidentifier
    FROM SERVICE YourMessageSendingService
    TO SERVICE 'YourMessageReceivingService'
    ON CONTRACT YourMessageContract
SEND ON CONVERSATION @handle MESSAGE TYPE YourMessage (@Message)

RECEIVE TOP (1) CAST([message_body] AS XML)
    FROM YourMessageReceivingQueue;

USE master

DROP DATABASE [YourDatabase]


  • The “SET ENABLE_BROKER” is called with “ROLLBACK IMMEDIATE” because of this.
  • The validation on the Message Type is “WELL_FORMED_XML” which does as described. If you want schema validation you can do but it gets complicated.
  • You can use encryption but then you need to create and manage Master Keys.
  • For communication between SQL Server instances, you need to create Routes.

Wednesday, 16 March 2011

Changing the collation on an existing SQL Server 2008 instance

If you have a SQL Server 2008 installation and wish to change the collation, you can run the following:


Where “MSSQLSERVER” is the default instance name (you can change this to a named instance) and the rest of the parameters are fairly self explanatory.

Note that user databases will not be updated, only the system databases (Master etc).

To update any user databases you need to:

  • Export all data from user databases using something like the BCP utility.
  • Drop all user databases
  • Update collation using above command
  • Create user databases
  • Import the data that you exported

Note that a back-up and restore of user databases does not work. In that scenario you simply restore the previous collation. You need to create an entirely new database and import the data.

Thursday, 10 February 2011


[Vendor representative],

I knew at the start of this process you were unlikely to change your implementation soon, certainly not within timescales which we could take advantage of for our delivery. However, I strongly disagree with your comments around SOAP Faults.

Your current implementation makes it difficult for consumers to work with your API and creates significant additional work to deal with error conditions returned from the API. When your service returns a response and I have to interrogate that response to find out if the request was successful, this is extra work for me. Were your service to return SOAP Faults, I can do something like the following (this is code from an internally developed web service at [my employer]):

      FindResponse findResponse = userService.Find(findRequest);
      Session["LoggedInUser"] = findResponse.User;
catch (FaultException<UserNotFoundFault>)
      // rather than quit just return the user being unknown
      User user = new User();
      user.Fullname = "Unknown User";
      this.Session["LoggedInUser"] = user;

You can see that I am able to deal with the SOAP Fault returned from the User Service using normal exception handling. In this particular use case, the application does not care that the user is not found and can continue. Other consumers of the User Service may choose to act differently, maybe the user not being found is a problem for other consumers and they can act accordingly.

Where I have to examine the response from a service to see if it was successful or not (as in the case of the [vendor] services) I have to start examining response objects rather than using exception handling. This is unnatural and prone to bugs. This creates unnecessary work for me as a consumer of your service (extra development, extra testing).

Using SOAP Faults, I can also deal with different error conditions easily:

           // Call some service
     catch (FaultExcpetion<BusinessErrorA>)
           // Do some corrective action
     catch (FaultExcpetion<BusinessErrorB>)
           // Do some other corrective action
     catch (FaultExcpetion<BusinessErrorC>)
           // Do something else

I have no such options with your service and I have to jump through hoops to look at the response object to find out what happened.

The problem is compounded further when using BPM/integration/messaging platforms like BizTalk. In BizTalk there are standard Orchestration steps/tasks to deal with exceptions. However, the lack of SOAP Faults in your service means there are no exceptions so I have to devise a custom solution to see if there was an error in the response object. Again, this creates yet more work for me the consumer of your service.

Furthermore, the error messages you provide are simply serialised exceptions, many of them are not helpful. We have seen your service return a “Null Reference Exception” which simply says “Object reference not set to an instance of an object”. As the consumer of your service, what am I supposed to do with that information? What remedial action can I take? I don’t know because I have no way to know what went wrong. Looking at the User Service example above I know what errors to expect (the SOAP Faults in the service contract) so I know what the business logic should be for the consumer. Even when your service might return a helpful error message, I have no way of knowing I will get it without the trial and error of calling your service to find out. Again, this is more work for me.

I’ll re-iterate my previous comments that as per the SOAP specification, errors should be returned as SOAP Faults (

It may be more effort for you to provide SOAP Faults in your service contract but as the publisher of a service it is your responsibility to do so. As a consumer your service, who is paying for the product, I expect you to do so. Yes, SOAP Faults mean you have a standard set of error messages. If you are unable to provide these because you do not know all of your error conditions, as a publisher of a service, you have bigger problems. This also links back to creating a lot of work for the consumer of your services. If you do not publish the list of error conditions, that does not mean error conditions do not exist, it means your consumers have to find them by trial and error.

You have shifted the cost of maintaining a set of SOAP Faults from yourself to the consumer who must come up with a custom way to find out if there is an error, work out the fault conditions by trial and error and guess at what remedial actions might be. This creates a lot of extra development and testing for consumers. As a consumer of your service, who is paying for it, I am less than happy with this.

I strongly suggest you reconsider your position for future releases of your product.



Tuesday, 25 January 2011

Configuring TFS 2010 with SharePoint 2010

Some link juice for this guy:

His instructions worked perfectly, no gotchas encountered.

Not sure I like what Microsoft has done with Team Build in TFS2010 though.

Wednesday, 12 January 2011

The size of Amazon’s cloud

According to a recent article from The Economist, it is estimated that Amazon are adding 90,000 virtual machines to their cloud every day.

That is a staggering number and (as the article notes) suggests that Amazon’s cloud is a bigger business than previously though.

The second cool thing in the article is the description of how the estimate was made. The “serial numbers” of the virtual machines were decrypted allowing for an accurate estimate to be made (I assume the serial number contains some sort of incrementing number). As is also noted in the article, this technique was similar to how the allies estimated the number of German tanks in existence in World War 2. This information was required to determine the feasibility of the Normandy landings – too many tanks would have made the landings a no-go. Relying on remorseless German efficiency and process, the allies used the serial numbers of captured German tanks to guess how many of them were being produced per month. The allies estimated 256, German records discovered later showed it to be 255.

About Me