Nicolas92
Nicolas92

Reputation: 23

Get Azure virtual machine status

Any help, how I can get virtual machines current status?

Image

I've tried these, but I cannot get example status "Stopped".

Console.WriteLine(role.RoleName);
//Console.WriteLine(role.ResourceExtensionReferences[0].State);
//Console.WriteLine(deployment.RoleInstances[0].PowerState);
//Console.WriteLine(client.Deployments.GetBySlot("demovm", DeploymentSlot.Production).Status);

Any clues/ideas, what I'm missing?

Upvotes: 2

Views: 2183

Answers (1)

stackpointcloud
stackpointcloud

Reputation: 64

You would use the following:

http://msdn.microsoft.com/en-us/library/azure/ee460806.aspx

Ensure embed-detail is true and you'll get a list of all nodes within the cloud service.

  <RoleInstanceList>
    <RoleInstance>
      <RoleName>name-of-role</RoleName>
      <InstanceName>name-of-role-instance</InstanceName>
      <InstanceStatus>status-of-role-instance</InstanceStatus>
      <InstanceUpgradeDomain>update-domain-of-role-instance</InstanceUpgradeDomain>
      <InstanceFaultDomain>fault-domain-of-role-instance</InstanceFaultDomain>
      <InstanceSize>size-of-role-instance</InstanceSize>
      <InstanceStateDetails>state-of-role-instance</InstanceStateDetails>
      <InstanceErrorCode>error-code-returned-for-role-instance</InstanceErrorCode>
      <IpAddress>ip-address-of-role-instance</IpAddress>
      <InstanceEndpoints>
        <InstanceEndpoint>
          <Name>name-of-endpoint</Name>
          <Vip>virtual-ip-address-of-instance-endpoint</Vip>
          <PublicPort>public-facing-port-of-instance-endpoint</PublicPort>
          <LocalPort>internal-facing-port-of-instance-endpoint</LocalPort>
          <Protocol>protocol-of-instance-endpoint</Protocol>
        </InstanceEndpoint>
      </InstanceEndpoints>
      <PowerState>state-of-role-instance</PowerState>
      <HostName>dns-name-of-service</HostName>
      <RemoteAccessCertificateThumbprint>cert-thumbprint-for-remote-access</RemoteAccessCertificateThumbprint>
    </RoleInstance>
  </RoleInstanceList>

You have InstanceStatus and PowerState to choose from depending on what you're looking for. Not the most intuitive place to look I agree.

Upvotes: 3

Related Questions