虚拟机生命周期和状态Virtual machines lifecycle and states

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.

电源状态Power states

电源状态表示 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.
状态State 说明Description 实例使用计费Instance usage billing

正在启动Starting

VM 正在启动。VM is starting up.

"statuses": [
{
"code": "PowerState/starting",
"level": "Info",
"displayStatus": "VM starting"
}
]

不计费Not billed

正在运行Running

VM 的正常工作状态Normal working state for a VM

"statuses": [
{
"code": "PowerState/running",
"level": "Info",
"displayStatus": "VM running"
}
]

计费Billed

正在停止Stopping

这是一种过渡性状态。This is a transitional state. 完成后,会显示为“已停止”。When completed, it will show as Stopped.

"statuses": [
{
"code": "PowerState/stopping",
"level": "Info",
"displayStatus": "VM stopping"
}
]

计费Billed

已停止Stopped

VM 已在来宾 OS 中关闭,或者已使用 PowerOff API 关闭。The VM has been shut down from within the guest OS or using the PowerOff APIs.

硬件仍然分配给 VM 并保留在主机上。Hardware is still allocated to the VM and it remains on the host.

"statuses": [
{
"code": "PowerState/stopped",
"level": "Info",
"displayStatus": "VM stopped"
}
]

不计费*Not billed*

正在解除分配Deallocating

过渡性状态。Transitional state. 完成后,VM 会显示为“已解除分配”。When completed, the VM will show as Deallocated.

"statuses": [
{
"code": "PowerState/deallocating",
"level": "Info",
"displayStatus": "VM deallocating"
}
]

不计费*Not billed*

已解除分配Deallocated

VM 已成功停止并从主机中删除。The VM has been stopped successfully and removed from the host.

"statuses": [
{
"code": "PowerState/deallocated",
"level": "Info",
"displayStatus": "VM deallocated"
}
]

不计费Not billed

*某些 Azure 资源(例如磁盘和网络)不管实例状态如何均收费。*Some Azure resources, such as Disks and Networking, incur charges regardless of the instance's state.

预配状态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。Create - VM creation.

  • 更新 - 更新现有 VM 的模型。Update - updates the model for an existing VM. 某些针对 VM 的非模型更改(例如“启动/重启”)也属于更新。Some non-model changes to VM such as Start/Restart also fall under update.

  • 删除 - 删除 VM。Delete - VM deletion.

  • 解除分配 - 是指停止 VM 并将其从主机中删除。Deallocate - is where a VM is stopped and removed from the host. 可以将 VM 的解除分配视为一种更新,因此它会显示与更新相关的预配状态。Deallocating a VM is considered an update, so it will display provisioning states related to updating.

下面是在平台接受用户启动的操作之后的过渡操作状态:Here are the transitional operation states after the platform has accepted a user-initiated action:


状态States

说明Description

正在创建Creating

"statuses": [
{
"code": "ProvisioningState/creating",
"level": "Info",
"displayStatus": "Creating"
}

正在更新Updating

"statuses": [
{
"code": "ProvisioningState/updating",
"level": "Info",
"displayStatus": "Updating"
}
]

正在删除Deleting

"statuses": [
{
"code": "ProvisioningState/deleting",
"level": "Info",
"displayStatus": "Deleting"
}
]

OS 预配状态OS provisioning states

如果 VM 是使用 OS 映像而非专用映像创建的,可能会观察到以下子状态:If a VM is created with an OS image and not with a specialized image, then following substates can be observed:

1. OSProvisioningInprogress – VM 正在运行,来宾 OS 的安装正在进行。1. OSProvisioningInprogress – The VM is running, and installation of guest OS is in progress.

"statuses": [
{
"code": "ProvisioningState/creating/OSProvisioningInprogress",
"level": "Info",
"displayStatus": "OS Provisioning In progress"
}
]

2. OSProvisioningComplete – 短时状态。2. OSProvisioningComplete – Short-lived state. VM 会快速过渡到“成功”状态,除非需要安装扩展。The VM quickly transitions to Success unless any extensions need to be installed. 安装扩展可能需要一定的时间。Installing extensions can take time.
"statuses": [
{
"code": "ProvisioningState/creating/OSProvisioningComplete",
"level": "Info",
"displayStatus": "OS Provisioning Complete"
}
]

注意:如果存在 OS 故障或者 OS 没有及时安装,则 OS 预配可能会过渡到“失败”状态。Note: OS Provisioning can transition to Failed if there is an OS failure or the OS doesn't install in time. 会根据部署在基础结构上的 VM 对客户收费。Customers will be billed for the deployed VM on the infrastructure.

操作完成后,VM 会过渡到下述某个状态:Once the operation is complete, the VM will transition into one of the following states:

  • 成功 - 用户启动的操作已完成。Succeeded - the user-initiated actions have completed.

    "statuses": [ 
    {
     "code": "ProvisioningState/succeeded",
     "level": "Info",
     "displayStatus": "Provisioning succeeded",
     "time": "time"
    }
    ]
    
  • 失败 - 表示操作失败。Failed - represents a failed operation. 若要获取详细信息和可能的解决方案,请查看错误代码。Refer to the error codes to get more information and possible solutions.

    "statuses": [
    {
      "code": "ProvisioningState/failed/InternalOperationError",
      "level": "Error",
      "displayStatus": "Provisioning failed",
      "message": "Operation abandoned due to internal error. Please try again later.",
      "time": "time"
    }
    ]
    

VM 实例视图VM 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.

后续步骤Next steps

若要详细了解如何监视 VM,请参阅如何监视 Azure 中的虚拟机To learn more about monitoring your VM, see How to monitor virtual machines in Azure.