Can I be able to change the instances count of a worker role while the application is running.
I have created an application which executes a sequence of code parallely a number of times depending on the user's query. Say, If user request the result to be very accurate, then I will have to run the code for 1000 or more times parallely on different datasets. If user doesn't request the result to be accurate, then I will run the code for 5 times parallely. This sequence of code is executed by a worker role. I will start the my application with the instances count of a worker role to be 5. If the user request the result to be very accurate, then can I increment the instances count of the worker role to say 20. Once the request is finished, I will set the instances count back to 5.
Can I do this. How can I do this. Will the application gets restarted if I do this.
Yes, you can do this. Windows Azure exposes management API to perform tasks as provisioning and deprovisioning additional worker roles.
You could check out Auto-scaling interfaces of Lokad.Cloud project: http://code.google.com/p/lokad-cloud/wiki/AutoScaling
Within a QueueService or a ScheduledService, you can access the property CloudService.Providers.Provisioning which will grant you a programmatic access to cloud fabric in order to adjust the number of workers running for your application.