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 -