Azure Elasticity– Part 2
In the last post I wrote about elasticity policy that defines when to change the number of instances.
In this post I will write about how to actually do that.
Let us say you have a service with 2 instances and you want to increment the number of instances by 1.
The simplest way to that is using the portal.



Well it is nice and easy but it is not automated. Maybe this is a good thing. Remember: More instances means more money to pay ! The fact that the process of creating an instance is not automated means that we stay in full control. On the other hand humans are slow and expensive and if there is no human around (weekends…) we might find ourselves with not enough computing resources for quite some time.
The second option is to use powershell

The scripts to increment the number of instances would look something like this
$cert = Get-Item cert:\CurrentUser\My\CertName
$sub = "CCCEA07B-1E9A-5133-8476-3818E2165063"
$servicename = 'myazureservice'
$package = "c:\publish\MyAzureService.cspkg"
$config = "c:\publish\ServiceConfiguration.cscfg"
Add-PSSnapin AzureManagementToolsSnapIn
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
Get-Deployment -Slot Production |
Set-DeploymentStatus 'Running' |
Get-OperationStatus -WaitToComplete
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub |
Get-Deployment -Slot Production |
Set-DeploymentConfiguration {$_.RolesConfiguration["WebUx"].InstanceCount += 1}
To automate this you can spin a process that will run powershell yourscript.cmd .As I wrote in the last post you can create rules and monitor performance characteristics to decide when to run the script.
Another option is to use the management API.
The management API is a REST API that can be used to execute any management task that can be executed in the portal.
csManage is a command line tool that abstracts the API. This is a sample provided with Windows Azure Samples so you have the code. It is easy to convert this to a simple API that you can use in your project
you can read interesting post franksie wrote about csManage.
The last Option I would like to talk about is "Elasticity using tools".
Here we are in the beginning of the road… I imagine that many tools are being developed right now (Including System Center Support)
Igor Papirov pointed me to nice tools (but a little expensive) called AzureWatch that automate exactly what I described in these two posts. It will monitor the performance of your app and then it will spin new instances or kill existing instances according to your rules.
Well now it is for you to decide how to implement elasticity.
Enjoy
Manu