gpt4 book ai didi

c# - 获取 Azure 虚拟机状态

转载 作者:行者123 更新时间:2023-12-02 23:34:01 25 4
gpt4 key购买 nike

有什么帮助吗?我如何获取虚拟机的当前状态?

Image

我已经尝试过这些,但无法获得示例状态“已停止”。

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);

有什么线索/想法吗?我缺少什么?

最佳答案

您将使用以下内容:

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

确保 embed-detail 为 true,您将获得云服务中所有节点的列表。

  <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>

您有 InstanceStatusPowerState 可供选择,具体取决于您要查找的内容。我同意这不是最直观的地方。

关于c# - 获取 Azure 虚拟机状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24990451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com