Azure Scale Application - Increase Or Decrease the number of role Instance
Undoubtedly one of the best feature of Windows Azure is to allow you scale your hosted service based on demand by increasing and decreasing number of role instances part of your hosted service. This not only helps business with increases customer satisfaction but also save cost.
Behind the Scene
This is achieved by defining the Value of role instance count in the Instances element within the service configuration file. Now as and when needed you can update service configuration file.
<Role name="XYZ">
<Instances count="1" />
<ConfigurationSettings>
How to Increase Or Decrease the number of Role Instance
Scaling of application can be done in multiple ways
Using Windows Azure Portal , I found this article really useful to perform this task
by modifying existing service configuration file
by uploading new updated service configuration file
Using Rest API - The Windows Azure Service Management REST API also exposes operations allowing the service configuration to be replaced with a new version containing different instance counts for the roles.
Using Set-RoleInstanceCount Windows Azure Platform PowerShell cmdlets, which allow various Service Management REST API operations to be invoked directly from PowerShell.
For one of my recent project i created following is powershell code
Increase the number of role Instance
cls
Add-PSsnapin AzureManagementToolsSnapin
Add-PsSnapin WAPPSCmdlets
#Subscription-Id of my Subscription
$subscriptionId = '8a27c306-9434-4d59-971a-c3dc82dcwerew'
#Thumbprint of certificated used to manage Subscriptin. This certificated should be already added to subscription
$Certificate = Get-Item cert:\LocalMachine\My\22598061DFB6543663E2D1A4C70045F528234
$hostedServiceName ='hostedservicename'
$slot="Production"
$rolename="RoleName"
$rolecount=(Get-RoleInstanceCount -SubscriptionId $subscriptionId -Certificate $Certificate -DeploymentSlot $slot -RoleName $rolename -ServiceName $hostedServiceName).instancecount
$rolecount=$rolecount + 1
Set-RoleInstanceCount -SubscriptionId $subscriptionId -Certificate $Certificate -DeploymentSlot $slot -RoleName $rolename -ServiceName $hostedServiceName -Count $rolecount | Get-OperationStatus -WaitToComplete
Remove-PSsnapin AzureManagementToolsSnapin
Remove-PSsnapin WAPPSCmdlets
Decrease the number of Role Instance
cls
Add-PSsnapin AzureManagementToolsSnapin
Add-PsSnapin WAPPSCmdlets
#Subscription-Id of my Subscription
$subscriptionId = '8a27c306-9434-4d59-971a-c3dc82dcwerew'
#Thumbprint of certificated used to manage Subscriptin. This certificated should be already added to subscription
$Certificate = Get-Item cert:\LocalMachine\My\22598061DFB6543663E2D1A4C70045F528234
$hostedServiceName ='hostedservicename'
$slot="Production"
$rolename="RoleName"
$rolecount=(Get-RoleInstanceCount -SubscriptionId $subscriptionId -Certificate $Certificate -DeploymentSlot $slot -RoleName $rolename -ServiceName $hostedServiceName).instancecount
$rolecount
if ($rolecount -gt 1)
{
$rolecount=$rolecount - 1
$rolecount
Set-RoleInstanceCount -SubscriptionId $subscriptionId -Certificate $Certificate -DeploymentSlot $slot -RoleName $rolename -ServiceName $hostedServiceName -Count $rolecount | Get-OperationStatus -WaitToComplete
}
Remove-PSsnapin AzureManagementToolsSnapin
Remove-PSsnapin WAPPSCmdlets
I am sure you will find this article helpful. Please rate this article and share your comments. For more details please feel free to contact me at arunrakwal@yahoo.com and I will be happy working with you.
Comments
- Anonymous
May 10, 2012
Arun,There are also 3rd party solutions like AzureWatch from http://www.paraleap.com that will monitor & auto-scale Azure applications with all sorts of bells and whistles, and Microsoft's own WASABi application block @ blogs.msdn.com/.../windows-azure-autoscaling-application-block-wasabi-beta-is-ready-for-you-to-try.aspx