Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programatically set the instance count for an Azure compute service

Tags:

cloud

azure

I read here that it is possible to programmatically set the instance count of an Azure compute service role using the Rest API method Change Deployment Configuration.

However the docs for that method don't mention role instances, just some cryptic extension properties. Does anyone know how this is done and can perhaps provide some pointers or a code snippet?

It's not the AutoScaling that I'm interested in, but being able to set the exact number of instances in response to custom events.

like image 943
Toby Sharp Avatar asked Dec 12 '13 10:12

Toby Sharp


2 Answers

In case you're interested in increasing instance count, then only way to do so is setting the new instance count in service configuration file and then performing Change Deployment Configuration operation as you mentioned. Do take a look at Windows Azure PowerShell Cmdlets as it has a Cmdlet called Set-AzureRole which will do the job for you.

Similarly if you want to reduce the number of instances, again you can take the same approach. With this approach instances are removed from bottom to top e.g. if you have 4 instances running (X_IN_0, X_IN_1, X_IN_2, and X_IN_3) and you want to remove 2 instances, then always X_IN_3 and X_IN_2 are removed). So if you don't care if last instances are removed, then you can use the same approach.

However there's a new operation available in Windows Azure Service Management API which gives you the power of removing specific instance: Delete Role Instances. You can read about that operation here: http://msdn.microsoft.com/en-us/library/windowsazure/dn469418.aspx. This is really handy if you wish to take out one particular instance which is behaving erratically. I wrote a blog post about the same which you can read here: http://gauravmantri.com/2013/10/16/a-new-version-of-windows-azure-service-management-api-is-available-with-delete-specific-role-instances-and-more-goodies/.

like image 119
Gaurav Mantri Avatar answered Sep 28 '22 12:09

Gaurav Mantri


There is a Set-AzureRole cmdlet, which lets you specify the number of instances Set-AzureRole (MSDN reference)

Here is an example:

Set-AzureRole -ServiceName $service -Slot $slot -RoleName "your-role-name" -Count 1

like image 39
Oleg D. Avatar answered Sep 28 '22 10:09

Oleg D.