Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Restarting Azure Worker role "WaWorkerHost.exe" manually

As I understand Azure Worker roles run by the help of Host application called WaWorkerHost.exe and there is another application called WaHostBootstrapper.exe which checks if WaWorkerHost.exe is running and if not it will run the WaWorkerHost.exe.

  1. How often does this 'worker role status check' occurs?
  2. How can I quickly restart the Worker role myself? I can either reboot the machine worker role is running and wait for few minutes or chose the following traditional method:

    Taskkill /im /f WaWorkerHost.exe

    and wait for few minutes for the WaHostBootstrapper.exe to kick in but this very inefficient and slow. Is there any (instant)method of restarting the worker role?

  3. Can I run something like the following and expect similar results to the WaHostBootstapper.exe or there are other consideration?

    WaWorkerHost.exe {MyAzureWorkerRole.dll}

like image 280
MHOOS Avatar asked Jun 14 '16 10:06

MHOOS


1 Answers

  1. The bootstrapper checks the WaWorkerHost status every 1 second.
    You can see it in the bootsrapper logs (c:\resources\WaHostBootstrapper.txt), by looking at interval of the trace:

"Getting status from client WaWorkerHost.exe"


  1. You can use AzureTools which is a utility used by Azure support team.

One of the its features is gracefully recycle the role instance:

enter image description here

Alternatively, you can restart the instance programmatically:

  • Upload management certificate to your subscription.
  • Use the following code to programmatically restart the instance:

Using 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. This is not recommended, for three reasons:

    1. The bootsrapper checks every second, which should be enough for most cases.
    2. It could lead to weird issues. For example, you kill the worker, bootstrapper identifies that the worker is down, you manually start the worker, bootstrapper also tries to start the worker and fail (will crash? will enter zombie state?). It can lead to unhealthy bootstrapper, means that nothing takes care of the worker process.
    3. It depends, of course, on what's the bootstrapper does other than starting the worker. But even if it is currently does nothing other than starting the role, you cannot know for sure if tomorrow Azure team will decide to add it more responsibilities/actions.
like image 128
yonisha Avatar answered Nov 09 '22 21:11

yonisha