English 中文(简体)
能否找到“谁”?
原标题:Can I find Azure role type (worker or web)?
  • 时间:2012-01-16 08:46:03
  •  标签:
  • azure

是否找到了哪类角色(工人或网络)? 是否可使用阳性反应器?

thanks, Nava

问题回答

网络作用将在E:或F上设置一个网站夹:驱动力,你可以撰写几条法典,看看是否存在这一夹。 我无法想出一种办法。

public static bool IsWebRole()
{
    return (System.IO.Directory.Exists(@"E:sitesroot") || System.IO.Directory.Exists(@"F:sitesroot"));
}

我猜测你从<>RoleName和InstanceName。 GetHostedservice。 • 确保你提供<明星>嵌入-详细=true,以便了解服务部署的详细情况。

更多信息:

利用SDK 2.2 仍然无法找到比依靠角色名称更好和更可靠的解决办法。

public static bool IsWebRole()
{
    var roleName = RoleEnvironment.CurrentRoleInstance.Role.Name;
    var match = Regex.Match(roleName, ".*webrole.*?", RegexOptions.IgnoreCase);
    if (match.Success) return true;
    match = Regex.Match(roleName, ".*workerrole.*?", RegexOptions.IgnoreCase);
    if (match.Success) return false;
    throw new Exception(String.Format("Can t figure out role type of {0}", roleName));
}

这是在部署之中。 如果存在<<>WaWorkerHost>程序,则由工人发挥作用,否则就是网络作用。 也可以检查<>WaIISHost>。

    bool isWorkerRole = false;
    foreach (Process proc in Process.GetProcessesByName("WaWorkerHost"))
    {
        isWorkerRole = true;
    }           




相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...

热门标签