如何在经典部署模型中为 Windows 虚拟机配置可用性集How to configure an availability set for Windows virtual machines in the classic deployment model

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 部署中配置可用性集You can also configure availability sets in Resource Manager deployments.

自 2017 年 11 月 15 日起,仅在 Azure 门户中提供虚拟机。Starting November 15, 2017, virtual machines will be available only in the Azure portal.

可用性集可帮助虚拟机在停机期间(例如维护期间)保持可用。An availability set helps keep your virtual machines available during downtime, such as during maintenance. 在可用性集中放置两个或更多个类似配置的虚拟机,即可针对虚拟机运行的应用程序或服务创建保持其可用性所需的冗余。Placing two or more similarly configured virtual machines in an availability set creates the redundancy needed to maintain availability of the applications or services that your virtual machine runs. 有关工作原理的详细信息,请参阅管理虚拟机的可用性For details about how this works, see Manage the availability of virtual machines.

同时使用可用性集和负载均衡终结点是帮助确保应用程序一直可用并有效运行的最佳实践。It's a best practice to use both availability sets and load-balancing endpoints to help ensure that your application is always available and running efficiently. 有关负载均衡终结点的详细信息,请参阅 Azure 基础结构服务的负载均衡For details about load-balanced endpoints, see Load balancing for Azure infrastructure services.

可以使用以下两个选项中的一个,将经典虚拟机添加到可用性集中:You can add classic virtual machines into an availability set by using one of two options:

Note

在经典模型中,要放入同一可用性集的虚拟机必须属于同一云服务。In the classic model, virtual machines that you want to put in the same availability set must belong to the same cloud service.

选项 1:同时创建虚拟机和可用性集Option 1: Create a virtual machine and an availability set at the same time

可以使用 Azure 门户或 Azure PowerShell 命令来执行此操作。You can use either the Azure portal or Azure PowerShell commands to do this.

若要使用 Azure 门户:To use the Azure portal:

  1. 登录到 Azure 门户(如果未登录)。If you haven't already done so, sign in to the Azure portal.

  2. 单击“创建资源” > “计算”。Click Create a resource > Compute.

  3. 选择要使用的市场虚拟机映像。Select the Marketplace virtual machine image you wish to use. 可以选择创建 Linux 或 Windows 虚拟机。You can choose to create a Linux or Windows virtual machine.

  4. 对于所选的虚拟机,确认部署模型已设置为“经典”,然后单击“创建”For the selected virtual machine, verify that the deployment model is set to Classic and then click Create

    Alt 图像文本

  5. 输入虚拟机名称、用户名和密码(适用于 Windows 虚拟机)或 SSH 公钥(适用于 Linux 虚拟机)。Enter a virtual machine name, user name and password (for Windows machines) or SSH public key (for Linux machines).

  6. 选择 VM 大小,然后单击“选择”继续。Choose the VM size and then click Select to continue.

  7. 选择“可选配置”>“可用性集”,并选择要将虚拟机添加到的可用性集。Choose Optional Configuration > Availability set, and select the availability set you wish to add the virtual machine to.

    Alt 图像文本

  8. 查看配置设置。Review your configuration settings. 完成后,单击“创建”。When you're done, click Create.

  9. 当 Azure 创建虚拟机时,可以在中心菜单的“虚拟机”下跟踪进度。While Azure creates your virtual machine, you can track the progress under Virtual Machines in the hub menu.

要使用 Azure PowerShell 命令创建 Azure 虚拟机并将它添加到新的或现有的可用性集,请参阅使用 Azure PowerShell 创建和预配置基于 Windows 的虚拟机To use Azure PowerShell commands to create an Azure virtual machine and add it to a new or existing availability set, see Use Azure PowerShell to create and preconfigure Windows-based virtual machines

选项 2:将现有虚拟机添加到可用性集Option 2: Add an existing virtual machine to an availability set

在 Azure 门户中,可以将现有经典虚拟机添加到现有可用性集,或为现有经典虚拟机创建新的可用性集。In the Azure portal, you can add existing classic virtual machines to an existing availability set or create a new one for them. (请记住,同一可用性集中的虚拟机必须属于同一云服务。)步骤几乎完全相同。(Keep in mind that the virtual machines in the same availability set must belong to the same cloud service.) The steps are almost the same. 使用 Azure PowerShell 时,可以将虚拟机添加到现有可用性集。With Azure PowerShell, you can add the virtual machine to an existing availability set.

  1. 如果尚未登录 Azure 门户,请先登录。If you have not already done so, sign in to the Azure portal.

  2. 在左侧菜单中单击“虚拟机(经典)”。On the left menu, click Virtual Machines (classic).

    Alt 图像文本

  3. 从虚拟机列表中,选择想要添加到集中的虚拟机的名称。From the list of virtual machines, select the name of the virtual machine that you want to add to the set.

  4. 从虚拟机的“设置”中选择“可用性集”。Choose Availability set from the virtual machine Settings.

    Alt 图像文本

  5. 选择要将虚拟机添加到的可用性集。Select the availability set you wish to add the virtual machine to. 虚拟机必须与可用性集属于同一云服务。The virtual machine must belong to the same cloud service as the availability set.

    Alt 图像文本

  6. 单击“保存” 。Click Save.

若要使用 Azure PowerShell 命令,请打开系统管理员级的 Azure PowerShell 会话并运行以下命令。To use Azure PowerShell commands, open an administrator-level Azure PowerShell session and run the following command. 对于占位符(例如 <VmCloudServiceName>),请将引号内的所有内容(包括 < 和 > 字符)替换为正确的名称。For the placeholders (such as <VmCloudServiceName>), replace everything within the quotes, including the < and > characters, with the correct names.

Get-AzureVM -ServiceName "<VmCloudServiceName>" -Name "<VmName>" | Set-AzureAvailabilitySet -AvailabilitySetName "<AvSetName>" | Update-AzureVM

Note

虚拟机可能必须重新启动,以完成将其添加到可用性集的操作。The virtual machine might have to be restarted to finish adding it to the availability set.