简体   繁体   English

如何检查辅助角色是否在Azure模拟器中运行

[英]How to check if Worker Role is running in Azure Emulator

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. 我有2个工作者角色,其中一个不应该在本地运行,但由于它们都在同一个Azure云项目中,因此它们都运行。

One way around it is to use #if !DEBUG and surround all the code inside the main loop, but it feels wrong. 一种方法是使用#if !DEBUG并包围主循环内的所有代码,但感觉不对。

Is there something like ASP.Net's Request.IsLocal ? 是否有类似ASP.Net的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. 投票重新打开 :虽然我毫不怀疑这个问题在最严格意义上是重复的,但是从这里链接的问题仅使用旧的术语,并且今天搜索Windows Azure术语的人永远不会发现这个问题。 SDK当前使用的namings。

The easiest way is to check it via RoleEnvironment.IsEmulated . 最简单的方法是通过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; 如果角色实例在计算模拟器中运行,则为true; otherwise, false. 否则,错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM