将 Linux 虚拟机重新部署到新的 Azure 节点Redeploy Linux virtual machine to new Azure node

如果在对 SSH 或应用程序访问 Azure 中 Linux 虚拟机 (VM) 进行故障排除时遇到困难,重新部署 VM 可能会有帮助。If you face difficulties troubleshooting SSH or application access to a Linux virtual machine (VM) in Azure, redeploying the VM may help. 重新部署 VM 时,将 VM 移到 Azure 基础结构中的新节点,并重新提供支持。When you redeploy a VM, it moves the VM to a new node within the Azure infrastructure and then powers it back on. 所有配置选项和关联资源均保留。All your configuration options and associated resources are retained. 本文介绍如何使用 Azure CLI 或 Azure 门户重新部署 VM。This article shows you how to redeploy a VM using Azure CLI or the Azure portal.

Note

重新部署 VM 后,临时磁盘将丢失,与虚拟网络接口关联的动态 IP 地址将更新。After you redeploy a VM, the temporary disk is lost and dynamic IP addresses associated with virtual network interface are updated.

使用 Azure CLIUse the Azure CLI

安装最新的 Azure CLI 并使用 az login 登录到 Azure 帐户。Install the latest Azure CLI and log in to your Azure account using az login.

Note

在 Azure China 中使用 Azure CLI 2.0 之前,请首先运行 az cloud set -n AzureChinaCloud 更改云环境。Before you can use Azure CLI 2.0 in Azure China, please run az cloud set -n AzureChinaCloud first to change the cloud environment. 如果要切换回全局 Azure,请再次运行 az cloud set -n AzureCloudIf you want to switch back to Global Azure, run az cloud set -n AzureCloud again.

使用 az vm redeploy 重新部署 VM。Redeploy your VM with az vm redeploy. 以下示例在名为 myResourceGroup 的资源组中重新部署名为 myVM 的 VM:The following example redeploys the VM named myVM in the resource group named myResourceGroup:

az vm redeploy --resource-group myResourceGroup --name myVM 

使用 Azure 经典 CLIUse the Azure classic CLI

安装最新的 Azure 经典 CLI 并登录到 Azure 帐户。Install the latest Azure classic CLI and log in to your Azure account. 请确保处于资源管理器模式 (azure config mode arm)。Make sure that you are in Resource Manager mode (azure config mode arm).

以下示例在名为 myResourceGroup 的资源组中重新部署名为 myVM 的 VM:The following example redeploys the VM named myVM in the resource group named myResourceGroup:

azure vm redeploy --resource-group myResourceGroup --vm-name myVM 

使用 Azure 门户Use the Azure portal

  1. 选择想要重新部署的 VM,然后选择“设置”边栏选项卡中的“重新部署”按钮。Select the VM you wish to redeploy, then select the Redeploy button in the Settings blade. 可能需要向下滚动,查看包含“重新部署”按钮的“支持和故障排除”部分,如以下示例所示:You may need to scroll down to see the Support and Troubleshooting section that contains the 'Redeploy' button as in the following example:

    Azure VM 边栏选项卡

  2. 若要确认该操作,请选择“重新部署”按钮:To confirm the operation, select the Redeploy button:

    “重新部署 VM”边栏选项卡

  3. VM 准备好重新部署时,该 VM 的“状态”会更改为“正在更新”,如以下示例所示:The Status of the VM changes to Updating as the VM prepares to redeploy, as shown in the following example:

    VM 正在更新

  4. VM 在新的 Azure 主机上启动时,“状态”将更改为“正在启动”,如以下示例所示:The Status then changes to Starting as the VM boots up on a new Azure host, as shown in the following example:

    VM 正在启动

  5. VM 完成启动过程后,“状态”返回到“正在运行”,这表示 VM 已成功重新部署:After the VM finishes the boot process, the Status then returns to Running, indicating the VM has been successfully redeployed:

    VM 正在运行

后续步骤Next steps

如果在连接 VM 时遇到问题,可以在 SSH 连接故障排除详细的 SSH 故障排除步骤中找到特定的帮助。If you are having issues connecting to your VM, you can find specific help on troubleshooting SSH connections or detailed SSH troubleshooting steps. 如果无法访问在 VM 上运行的应用程序,还可以阅读 application troubleshooting issues(应用程序故障排除问题)。If you cannot access an application running on your VM, you can also read application troubleshooting issues.