Wednesday, January 22, 2014

Azure auto scaling based on CPU usage tutorial



Windows Azure has come up with built in Auto Scale feature on Azure Management Portal. Azure Auto Scale block can be used to perform this however one should use auto scale feature provided on Azure Management Portal itself.
An Azure hosted worker role can be auto scaled based on number of message in the Queue storage or based on CPU usage. If suppose you wish to autoscale the azure worker role based on CPU usage then to understand how it works I created following code. The code snippet given below actually performs heavy operations on Worker Role due to which the CPU usage on Azure Worker Role VM increases. Then the following screenshot depicts that how auto scale feature can be configured from Azure Management Portal.
Following code you can put within Run method within while loop having true condition -

Monday, January 13, 2014

How to build a solution using c# code in .NET 4.5 and retrieve the build result


Following is the code using which you can perform automated compilation of visual studio solutions through C#. First of all let’s retrieve the executing assembly path to write the output log of build activity performed using C#.
//retrieve assembly execution path
string assemblyExecutionPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
string logFilePath = assemblyExecutionPath.Remove(assemblyExecutionPath.LastIndexOf("\\") + 1) + "build.log";
Let’s create a collection to hold the output –
OutputHeaderRow = new List<string>();
OutputItemRow = new List<string>();
Let’s say the path of the solution to build using C# code is present in following variable - string artifactPath = @"C:\Kunal_AppDev\New folder\Test Data Solution\ MySolution.sln"
Following is the remaining complete code –

Monday, January 6, 2014

How to log on to TFS as different user

Sometime you may have to login to TFS with different user; however TFS by default picks up the user logged in to windows or previous connection details. I am using VS2012 currently hence will explain the process using VS2012 IDE only. Look at the following screenshot. When you click on Connect option in Team Explorer window by default you get connected to the required server with credentials you have used to log on last time and you are not prompted to change the login user.



This will force to ask new credentials when TFS is opened for connection.

Go to Control Panel (Start -> Control Panel).Click User Accounts. Click Credential Manager.