Tuesday, November 30, 2010

TFS 2010 BlueGreen Deployment with Amazon Elastic Load Balancer

One of the best ways to minimize the outage taken while deploying a website or webservice is by the use of Blue-Green deployment model. I've created a TFS 2010 deployment workflow that uses Amazon EC2 and does just that.

Step 1: Download and install the Amazon Elastic Load Balancer API tools and install on your build box. Make sure you are able to use the command line on your build box to register and deregister Amazon EC2 instances before continuing.

Step 2: Add a BlueInstanceIds and GreenInstanceIds String[] arguments to your build WF.

Step 3: Add a LoadBalancerName String argument to your build WF.

Step 4: Add a AWSAccessKeyId and AWSSecretAccessKey String arguments to your build WF.

Step 4: Add a Parrallel ForEach or a ForEach to your build WF that iterates over your GreenInstanceIds.

Step 5. Add an InvokeProcess activity to the body of your ForEach from step 3. The FileName property should point to elb-deregister-instances-from-lb.cmd. The Arguments should be set to LoadBalancerName & " --instances " & GreenServerInstanceId & " --I " & AWSAccessKeyId & " --S " & AWSSecretAccessKey

Step 6. Set your variables in your build definition.

Step 7. Run your build


This should successfully DeRegister any servers in the GreenServerInstanceIds variable. Follow the same concepts for Registering your Green servers as well as registering/deregistering your blue servers.

No comments: