In Part One, I showed you important artifacts in Windows Azure IaaS. Why they are needed and the sequence to create and deploy them. To better manage all resources in a deployment, my best practice is to tag all deployed. I normally create a tag based on the current timestamp and add the tag as a prefix to all resources associated with a deployment.

Below as an example is a function I wrote to process and add a prefix to the Affinity Groups appear in a NetworkConfig.xml file which defines the virtual network configuration of a Windows Azure subscription. An Affinity Group is an artifact to be created and associated with a virtual network such that all VMs deployed to the virtual network will be in the region specified by the Affinity Group. I use this function as a template for processing a node in NetworkConfig.xml or other xml files.


To test this function, you can simply use the NetworkConfig.xml you downloaded form Part One or will need to first export the NetworkConfig.xml file from an intended Windows Azure subscription, and provide it as a parameter of this function which you can download from here. 

The Tag should be something which once is added to a resource name will make the resource identifiable with a deployment. This will help and drastically simplify, for example, decommissioning resources of a deployment where by removing all resources with the same Tag. Particularly for demos, pilots, test runs, etc. it becomes very easy to process/delete a deployment as a whole. A sample call of the function while putting a target NetworkConfig.xml file in the root of c drive and using a timestamp as the Tag is like:

Tag_AffinityGroup –theNetcfgFile ‘c:\myNetworkConfig.xml’ –Tag (get-date –format ‘mmss’)

Here the Tag is a 4-byte string indicating the current minute and second. Since this Tag is to prefix an AffinityGroup name which in Windows Azure has a limit of 15 characters, the Tag can not be too long in size. The following shows a sample result that after calling the function, the Affinity Group is prefixed with a 4-character tag.


In Windows Azure Infrastructure Services (IaaS) Quick Start Kit (QSK), I will provide a routine for cleaning up deployed Windows Azure IaaS resources based on a specified prefix or pattern.