Azure 虚拟机的状态和计费States and billing of Azure Virtual Machines

Azure 虚拟机 (VM) 经历的不同状态可以归类为“预配”状态和“电源”状态。Azure Virtual Machines (VMs) go through different states that can be categorized into provisioning and power states. 本文旨在介绍这些状态并专门突出显示了何时会对客户收取实例使用费用。The purpose of this article is to describe these states and specifically highlight when customers are billed for instance usage.

使用实例视图获取状态Get states using Instance View

实例视图 API 提供 VM 运行状态信息。The instance view API provides VM running-state information. 有关详细信息,请参阅 Virtual Machines - Instance View(虚拟机 - 实例视图)API 文档。For more information, see the Virtual Machines - Instance View API documentation.

预配状态在 VM 属性和实例视图中可见。Provisioning states are visible on VM properties and instance view. 电源状态在 VM 的实例视图中提供。Power states are available in instance view of VM.

若要检索订阅中所有 VM 的电源状态,请使用虚拟机 - 列出所有 API,并将参数 statusOnly 设置为 true。To retrieve the power state of all the VMs in your subscription, use the Virtual Machines - List All API with parameter statusOnly set to true.


虚拟机 - 列出所有 API 的参数 statusOnly 设置为 true 后,它可以检索订阅中所有 VM 的电源状态。Virtual Machines - List All API with parameter statusOnly set to true will retrieve the power states of all VMs in a subscription. 但在一些罕见的情况下,由于检索过程中的间歇性问题,可能无法获取电源状态。However, in some rare situations, the power state may not available due to intermittent issues in the retrieval process. 在这种情况下,我们建议使用同一 API 重试,或者使用 Azure 资源运行状况Azure Resource Graph 来检查 VM 的电源状态。In such situations, we recommend retrying using the same API or using Azure Resource Health or Azure Resource Graph to check the power state of your VMs.

电源状态和计费Power states and billing

电源状态表示 VM 的上一个已知状态。The power state represents the last known state of the VM.

图像显示了 VM 可以经历的电源状态的示意图。

下表描述每个实例状态并指示是否会对其收取实例使用费用。The following table provides a description of each instance state and indicates whether it is billed for instance usage or not.

电源状态Power state 说明Description 计费Billing
正在启动Starting 虚拟机正在启动。Virtual Machine is powering up. 不计费*Not billed*
运行Running 虚拟机已启动。Virtual Machine is fully up. 这是标准工作状态。This is the standard working state. 计费Billed
正在停止Stopping 这是运行和停止之间的过渡状态。This is a transitional state between running and stopped. 计费Billed
已停止Stopped 虚拟机已在来宾 OS 中关闭或已使用 PowerOff API 关闭。The Virtual Machine is has been shut down from within the Guest OS or using PowerOff APIs. 在这种状态下,虚拟机仍在租用基础硬件。In this state, the virtual machine is still leasing the underlying hardware. 这种状态也称为“已停止(已分配)”。This state is also referred to as Stopped (Allocated). 计费Billed
正在解除分配Deallocating 这是运行和已解除分配之间的过渡状态。This is the transitional state between running and deallocated. 不计费*Not billed*
已解除分配Deallocated 虚拟机已解除对基础硬件的租用,并且已完全关闭电源。The Virtual Machine has released the lease on the underlying hardware and is completely powered off. 这种状态也称为“已停止(已解除分配)”。This state is also referred to as Stopped (Deallocated). 不计费*Not billed*

* 某些 Azure 资源(如磁盘网络)仍会继续产生费用。* Some Azure resources, such as Disks and Networking will continue to incur charges.

预配状态Provisioning states

预配状态是用户在 VM 上启动的控制平面操作的状态。A provisioning state is the status of a user-initiated, control-plane operation on the VM. 以下状态独立于 VM 的电源状态。These states are separate from the power state of a VM.

图像显示了 VM 可以经历的预配状态。

正在设置状态Provisioning state 说明Description 电源状态Power state 计费Billing
创建Create 创建虚拟机。Virtual machine creation. 正在启动Starting 不计费*Not billed*
更新Update 更新现有虚拟机的模型。Updates the model for an existing virtual machine. 对虚拟机的一些非模型更改,如启动和重启,都属于更新状态。Some non-model changes to a virtual machine such as start and restart fall under the update state. 运行Running 计费Billed
删除Delete 删除虚拟机。Virtual machine deletion. 正在解除分配Deallocating 不计费*Not billed*
释放Deallocate 虚拟机完全停止并从基础主机中删除。Virtual machine is fully stopped and removed from the underlying host. 可以将虚拟机的解除分配视为一种更新,因此它会显示与更新类似的预配状态。Deallocating a virtual machine is considered an update and will display provisioning states similar to updating. 正在解除分配Deallocating 不计费*Not billed*

* 某些 Azure 资源(如磁盘网络)仍会继续产生费用。* Some Azure resources, such as Disks and Networking will continue to incur charges.

OS 预配状态OS Provisioning states

OS 预配状态仅适用于使用 OS 映像创建的虚拟机。OS Provisioning states only apply to virtual machines created with an OS image. 专用映像将不会显示这些状态。Specialized images will not display these states.

图像显示了 VM 可以经历的 OS 预配状态。

OS 预配状态OS Provisioning state 说明Description 电源状态Power state 计费Billing
OSProvisioningInProgressOSProvisioningInProgress VM 正在运行,并且正在安装来宾 OS。The VM is running and the installation of the Guest OS is in progress. 运行Running 计费Billed
OSProvisioningCompleteOSProvisioningComplete 这是一种短暂的状态。This is a short-lived state. 虚拟机将从此状态快速转换为“成功”。The virtual machine quickly transitions from this state to Success. 如果仍在安装扩展,你将继续看到此状态,直到安装完成。If extensions are still being installed you will continue to see this state until they are complete. 运行Running 计费Billed
成功Succeeded 用户发起的操作已完成。The user-initiated actions have completed. 运行Running 计费Billed
失败Failed 表示操作失败。Represents a failed operation. 有关详细信息和可能的解决方案,请参阅错误代码。Refer to the error code for more information and possible solutions. 运行Running 计费Billed

后续步骤Next steps