调整在经典部署模型中创建的 Windows VM 的大小Resize a Windows VM created in the classic deployment model

本文说明如何使用 Azure Powershell 调整在经典部署模型中创建的 Windows VM 的大小。This article shows you how to resize a Windows VM, created in the classic deployment model using Azure Powershell.

在考虑调整 VM 大小的能力时,有两个概念控制可用于调整虚拟机大小的大小范围。When considering the ability to resize a VM, there are two concepts which control the range of sizes available to resize the virtual machine. 第一个概念是在其中部署 VM 的区域。The first concept is the region in which your VM is deployed. 在“Azure 区域”网页的“服务”选项卡下提供区域中可用的 VM 大小的列表。The list of VM sizes available in region is under the Services tab of the Azure Regions web page. 第二个概念是当前正在托管 VM 的物理硬件。The second concept is the physical hardware currently hosting your VM. 托管 VM 的物理服务器在常见物理硬件的群集中分组在一起。The physical servers hosting VMs are grouped together in clusters of common physical hardware. 更改 VM 大小的方法因当前托管 VM 的硬件群集是否支持所需的新 VM 大小而异。The method of changing a VM size differs depending on if the desired new VM size is supported by the hardware cluster currently hosting the VM.

Important

Azure 提供两个不同的部署模型用于创建和处理资源:Resource Manager 和经典模型Azure has two different deployment models for creating and working with resources: Resource Manager and Classic. 本文介绍如何使用经典部署模型。This article covers using the Classic deployment model. Azure 建议大多数新部署使用 Resource Manager 模型。Azure recommends that most new deployments use the Resource Manager model. 还可以调整在 Resource Manager 部署模型中创建的 VM 的大小You can also resize a VM created in the Resource Manager deployment model.

添加帐户Add your account

必须配置 Azure PowerShell 才能处理经典 Azure 资源。You must configure Azure PowerShell to work with classic Azure resources. 按照下面的步骤配置 Azure PowerShell 以管理经典资源。Follow the steps below to configure Azure PowerShell to manage classic resources.

  1. 在 PowerShell 命令提示符处,键入 Add-AzureAccount -Environment AzureChinaCloud 并单击“Enter”。At the PowerShell prompt, type Add-AzureAccount -Environment AzureChinaCloud and click Enter.
  2. 键入与 Azure 订阅相关联的电子邮件地址并单击“继续”。Type in the email address associated with your Azure subscription and click Continue.
  3. 键入帐户的密码。Type in the password for your account.
  4. 单击“登录” 。Click Sign in.

在同一硬件群集中调整大小Resize in the same hardware cluster

要将 VM 的大小调整为托管 VM 的硬件群集中可用的大小,请执行以下步骤。To resize a VM to a size available in the hardware cluster hosting the VM, perform the following steps.

  1. 运行以下 PowerShell 命令,列出托管包含 VM 的云服务的硬件群集中可用的 VM 大小。Run the following PowerShell command to list the VM sizes available in the hardware cluster hosting the cloud service which contains the VM.

    Get-AzureService | where {$_.ServiceName -eq "<cloudServiceName>"}
    
  2. 运行以下命令以调整 VM 大小。Run the following commands to resize the VM.

    Get-AzureVM -ServiceName <cloudServiceName> -Name <vmName> | Set-AzureVMSize -InstanceSize <newVMSize> | Update-AzureVM
    

在新的硬件群集上调整大小Resize on a new hardware cluster

要将 VM 的大小调整为托管 VM 的硬件群集中不可用的大小,必须重新创建云服务和云服务中的所有 VM。To resize a VM to a size not available in the hardware cluster hosting the VM, the cloud service and all VMs in the cloud service must be recreated. 单个硬件群集托管每个云服务,因此,云服务中的所有 VM 的大小必须都受单个硬件群集支持。Each cloud service is hosted on a single hardware cluster so all VMs in the cloud service must be a size that is supported on a hardware cluster. 以下步骤介绍如何通过删除并重新创建云服务来调整 VM 大小。The following steps will describe how to resize a VM by deleting and then recreating the cloud service.

  1. 运行以下 PowerShell 命令,列出区域中可用的 VM 大小。Run the following PowerShell command to list the VM sizes available in the region.

    Get-AzureLocation | where {$_.Name -eq "<locationName>"}
    
  2. 记下包含要调整大小的 VM 的云服务中每个 VM 的所有配置设置。Make note of all configuration settings for each VM in the cloud service which contains the VM to be resized.

  3. 删除云服务中的所有 VM 时选择保留每个 VM 的磁盘的选项。Delete all VMs in the cloud service selecting the option to retain the disks for each VM.

  4. 使用所需的 VM 大小重新创建要调整大小的 VM。Recreate the VM to be resized using the desired VM size.

  5. 使用现在托管云服务的硬件群集中可用的 VM 大小,重新创建云服务中原有的所有其他 VM。Recreate all other VMs which were in the cloud service using a VM size available in the hardware cluster now hosting the cloud service.

删除云服务并使用新的 VM 大小重新创建云服务的示例脚本可在 此处找到。A sample script for deleting and recreating a cloud service using a new VM size can be found here.

后续步骤Next steps