I'm working on a worker role failover solution and I need to be able to test and debug the failover mechanism by shutting down or restarting instances as well as creating new ones.
How do I restart or shutdown specific instances on the local Azure Emulator? I'm using the 1.7 SDK
Thanks,
I have to disagree with David's answer here. There are a few things you can do to shut down instances or create new instances.
When you run your application in the emulator it starts 1 Web Role (WaIISHost.exe) / Worker Role (WaWorkerHost.exe) process per instance:
When you kill one of these processes it's as if you killed an instance. After switching back to the emulator you'll see that the icon of that specific instance you killed changed color and the logs will show that the state of the instance is Unknown/Destroyed:
When the debugger is attached you'll see this happen and the instance will never restart, allowing you to test scenarios where you suddenly loose one or more instances. If the debugger is not attached this will all happen very fast and the instance will restart right away (in Visual Studio you can choose to start without debugging).
Using csrun.exe (usually located in C:\Program Files\Microsoft SDKs\Windows Azure\Emulator) you can update the configuration of your service in the emulator, including the number of instances. Let's say I want to add 6 instances to the 4 instances I have at the moment.
I open the ServiceConfiguration.cscfg file located in my Debug folder of your Azure project (..\Some\Path\MultipleInstancesDemo\MultipleInstancesDemo\bin\Debug) and change the number of instances to 10:
<ServiceConfiguration serviceName="MultipleInstancesDemo" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*" schemaVersion="2012-05.1.7">
<Role name="MyWebRole">
<Instances count="10" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
</ConfigurationSettings>
</Role>
</ServiceConfiguration>
Then it's possible to push this to the emulator by providing csrun.exe with the deployment ID and the path to the configuration file. You'll find the deployment ID in the emulator. In the previous screenshot you'll see deployment17(20), this means that the deployment ID is 20. This is how you would call csrun.exe: csrun /update:20;"..\Some\Path\MultipleInstancesDemo\MultipleInstancesDemo\bin\Debug\SeviceConfiguration.cscfg"
After a few seconds you'll see the new instances in the emulator:
Note!: Also here it seems that this only works when you start the project without debugging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With