Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have RoleEntryPoint.OnStop() called in Azure Compute Emulator?

I'm testing a trivial web role under Azure Compute Emulator and have overridden OnStart(), Run() and OnStop() methods in my class that derives from RoleEntryPoint.

OnStart() and Run() are called but OnStop() is not - I will either press "Stop debugging" in Visual Studio or close the browser window and the role will be terminated, but OnStop() is never called. I've checked - the override keyword is present in OnStop() definition.

That's not very convenient - it means I can't test my OnStop() outside a live cloud.

Can I somehow make Compute Emulator call OnStop() in my role?

like image 783
sharptooth Avatar asked Jun 16 '11 14:06

sharptooth


3 Answers

I suspect (but I'm not sure), that if you open the compute emulator UI and "stop" the deployment there, OnStop() should be called.

like image 83
user94559 Avatar answered Nov 15 '22 06:11

user94559


You can use csrun to update the configuration of a running deployment. When you give the command the instance will call the OnStop() method.

To update the ServiceConfigure:

  • Open the Azure SDK bin folder through the command line
  • Issue the command csrun.exe /update:{Deployment ID, just the number};{Path of the cscfg file}

In my Compute Emulator it would be:

  • csrun.exe /update:252;"D:\user\My Documents\Visual Studio 2010\Projects\CSM\CSC\bin\Debug\ServiceConfiguration.cscfg"
like image 32
ToinoBiclas Avatar answered Nov 15 '22 07:11

ToinoBiclas


If you intentionally exit from the Run() method, I believe OnStop() should be called.

like image 30
dunnry Avatar answered Nov 15 '22 08:11

dunnry