手动重启 Azure 辅助角色 "WaWorkerHost.exe"

Restarting Azure Worker role "WaWorkerHost.exe" manually

据我所知,Azure Worker 角色 运行 借助名为 WaWorkerHost.exe 的主机应用程序,还有另一个应用程序名为 WaHostBootstrapper.exe 检查 WaWorkerHost.exe 是否为 运行ning,如果不是,它将 运行 为 WaWorkerHost.exe

  1. 这种 'worker role status check' 多久发生一次?
  2. 如何自己快速重启Worker角色?我可以重新启动机器工作者角色 运行ning 并等待几分钟,或者选择以下传统方法:

    Taskkill /im /f WaWorkerHost.exe

    并等待 WaHostBootstrapper.exe 启动几分钟,但这非常低效且缓慢。 是否有任何(即时)方法重新启动工作者角色?

  3. 我可以 运行 像下面这样的东西并期待与 WaHostBootstapper.exe 类似的结果还是有其他考虑?

    WaWorkerHost.exe {MyAzureWorkerRole.dll}

如果角色本身知道它需要重新启动,它可以调用RoleEnvironment.RequestRecycle使角色实例重新启动。

  1. 引导程序每 1 秒检查一次 WaWorkerHost 状态。
    您可以在引导程序日志 (c:\resources\WaHostBootstrapper.txt) 中通过查看跟踪间隔来查看它:

"Getting status from client WaWorkerHost.exe"


  1. 您可以使用 AzureTools,这是 Azure 支持团队使用的实用程序。

它的一个特点是优雅地回收角色实例:

或者,您可以通过编程方式重新启动实例:

使用Microsoft Azure Compute Management library:

X509Certificate2 cert = new X509Certificate2("");
var credentials = new CertificateCloudCredentials("your_subscription_id", cert);

using (var managementClient = new ComputeManagementClient(credentials))
{
    OperationStatusResponse response =
        await managementClient.Deployments.RebootRoleInstanceByDeploymentSlotAsync(
            "cloud_service_name",
            DeploymentSlot.Production, // or staging
            "instance_name");
}

  1. 不推荐这样做,原因有以下三个:

    1. bootsrapper 每秒检查一次,这对于大多数情况应该足够了。
    2. 这可能会导致奇怪的问题。比如你把worker杀了,bootstrapper识别到worker挂了,你手动启动worker,bootstrapper也尝试启动worker失败了(会crash?会进入zombie状态?)。它会导致不健康的引导程序,意味着没有任何东西会照顾工作进程。
    3. 当然,这取决于引导程序除了启动工作程序之外还做了什么。但是,即使它目前除了启动角色之外什么都不做,您也无法确定明天 Azure 团队是否会决定添加更多 responsibilities/actions.