3

I was wondering if there was a way to check if the worker role was running inside the emulator. I have 2 worker roles and one of them shouldn't run locally, but since they are both in the same Azure Cloud Project, they both run.

One way around it is to use #if !DEBUG and surround all the code inside the main loop, but it feels wrong.

Is there something like ASP.Net's Request.IsLocal?

Vote To Reopen: While I have no doubt that this question is a duplicate in the strictest sense of the meaning, the question linked from here uses only the old terminology and would never have been found by a person searching today for the Windows Azure terms and namings that are currently used by the SDK.

Jeremy Boyd
  • 5,245
  • 7
  • 33
  • 57

1 Answers1

3

The easiest way is to check it via RoleEnvironment.IsEmulated. For more information have a look at this thread. According to the documentation it will return

true, if the role instance is running in the compute emulator; otherwise, false.

Community
  • 1
  • 1
Horizon_Net
  • 5,959
  • 4
  • 31
  • 34
  • Rather than posting an answer with a link to another SO question's answer, you should have voted to close this question as a duplicate, referencing the other question. – David Makogon Jul 08 '14 at 21:11
  • 1
    Thanks for the hint @DavidMakogon. Will remember that the next time. – Horizon_Net Jul 09 '14 at 09:05