你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

探讨 Linux 虚拟机规模集的 Azure 混合权益

Azure 混合权益可以降低运行 Red Hat Enterprise Linux (RHEL) 和 SUSE Linux Enterprise Server (SLES) 虚拟机规模集的成本。 Linux 虚拟机规模集的 Azure 混合权益现已正式发布。 它适用于 Azure 市场中的所有 RHEL 和 SLES 即用即付映像。

启用 Azure 混合权益时,产生的唯一费用是规模集基础结构的成本。

注意

本文重点介绍在统一业务流程模式下运行的虚拟机规模集。 建议对新工作负载使用灵活业务流程。 有关详细信息,请参阅 Azure 中虚拟机规模集的业务流程模式

什么是 Linux 虚拟机规模集的 Azure 混合权益?

利用 Azure 混合权益,可将虚拟机规模集切换到自带订阅 (BYOS) 计费。 可以使用 Red Hat 或 SUSE 提供的云访问许可证来实现。 还可以将即用即付实例切换到 BYOS,而无需重新部署。

启用 Azure 混合权益后,从即用即付 Azure 市场映像部署的虚拟机规模集需要支付基础结构和软件费用。

Diagram that shows the effect of Azure Hybrid Benefit on costs for Linux virtual machines.

哪些 Linux 虚拟机可以使用 Azure 混合权益?

Azure 混合权益可用于 Azure 市场中的所有 RHEL 和 SLES 即用即付映像。 Azure 混合权益尚不可用于 RHEL 或 SLES BYOS 映像或 Azure 市场中的自定义映像。

如果已在 Linux 虚拟机上使用 Azure 混合权益,则 Azure 专用主机实例和 SQL 混合权益不符合 Azure 混合权益的条件。

入门

启用 Red Hat 虚拟机规模集的 Azure 混合权益

RHEL 的 Azure 混合权益适用于满足以下条件的 Red Hat 客户:

  • 具有可在 Azure 中使用的有效或未使用的 RHEL 订阅
  • 已正确启用一个或多个订阅,以在 Azure 中用于 Red Hat Cloud Access 计划

开始使用 Red Hat 的 Azure 混合权益:

  1. 使用 Red Hat Cloud Access 客户界面在 Azure 中启用符合资格的 RHEL 订阅。

    在启用 Red Hat Cloud Access 的过程中提供的 Azure 订阅可以使用 Azure 混合权益。

  2. 将 Azure 混合权益应用于任何新的和现有 RHEL 即用即付虚拟机规模集。 可以使用 Azure 门户或 Azure CLI 来启用 Azure 混合权益。

  3. 若要配置 RHEL 虚拟机的更新源和获取 RHEL 订阅合规性指南,请遵循建议的后续步骤

启用 SUSE 虚拟机规模集的 Azure 混合权益

开始使用 SUSE 的 Azure 混合权益:

  1. 向 SUSE 公有云计划进行注册。
  2. 通过 Azure 门户或 Azure CLI 将 Azure 混合权益应用于新创建或现有的虚拟机规模集。
  3. 使用单独的更新源注册接收 Azure 混合权益的虚拟机。

在 Azure 门户中启用 Azure 混合权益

在创建虚拟机规模集期间启用 Azure 混合权益

  1. 转到 Azure 门户

  2. 转到“创建虚拟机规模集”。

    Screenshot of the portal page for creating a Virtual Machine Scale Set.

  3. 在“许可”部分中,选中询问你是否要使用现有 RHEL 订阅的复选框以及确认你的订阅符合条件的复选框。

    Screenshot of the Azure portal that shows checkboxes selected for licensing.

  4. 按照下一组说明创建虚拟机规模集。

  5. 在“操作系统”窗格中,确认该选项已启用。

    Screenshot of the Azure Hybrid Benefit pane for the operating system after you create a virtual machine.

在现有虚拟机规模集中启用 Azure 混合权益

  1. 转到 Azure 门户
  2. 打开要应用转换的虚拟机规模集的页面。
  3. 转到“操作系统”>“许可”。 若要启用 Azure 混合权益转换,请选择“是”,然后选中确认复选框。

Screenshot of the Azure portal that shows the Licensing section of the pane for the operating system.

使用 Azure CLI 启用和禁用 Azure 混合权益

在 Azure CLI 中,可使用 az vmss update 命令启用 Azure 混合权益。 对于 RHEL 虚拟机,使用 --license-type 参数 RHEL_BYOS 运行命令。 对于 SLES 虚拟机,使用 --license-type 参数 SLES_BYOS 运行命令。

# This will enable Azure Hybrid Benefit on a RHEL Virtual Machine Scale Set
az vmss update --resource-group myResourceGroup --name myVmName --license-type RHEL_BYOS

# This will enable Azure Hybrid Benefit on a SLES Virtual Machine Scale Set
az vmss update --resource-group myResourceGroup --name myVmName --license-type SLES_BYOS

若要禁用 Azure 混合权益,请使用 --license-typeNone

# This will disable Azure Hybrid Benefit on a virtual machine
az vmss update -g myResourceGroup -n myVmName --license-type None

注意

规模集有一项升级策略,用于确定虚拟机如何与最新的规模集模型保持同步。

如果规模集具有自动升级策略,则在更新虚拟机时将自动应用 Azure 混合权益。 如果规模集具有滚动升级策略,则根据计划的更新应用 Azure 混合权益。

如果规模集具有手动升级策略,则必须使用 Azure CLI 手动升级虚拟机:

# This will bring Virtual Machine Scale Set instances up to date with the latest Virtual Machine Scale Set model 
az vmss update-instances --resource-group myResourceGroup --name myScaleSet --instance-ids {instanceIds}

在创建时将 Azure 混合权益应用于虚拟机规模集

重要

从 2023 年 11 月开始,使用 PowerShell 和 Azure CLI 创建的 VM 规模集将默认为灵活业务流程模式(如果未指定业务流程模式)。 若要详细了解此更改以及你应采取哪些操作,请访问针对 VMSS PowerShell/CLI 客户的中断性变更 - Microsoft 社区中心

除了将 Azure 混合权益应用于现有的即用即付虚拟机规模集外,还可以在创建虚拟机规模集时调用它。 这样做有三重好处:

  • 可以使用相同的映像和进程预配即用即付和 BYOS 虚拟机规模集。
  • 它支持在将来更改许可模式。 这些更改是仅限 BYOS 的映像无法实现的。
  • 默认情况下,虚拟机规模集将连接到 Red Hat 更新基础结构 (RHUI),以帮助其保持最新和安全状态。 可以在部署后随时更改更新后的机制。

若要使用 Azure CLI 在创建时将 Azure 混合权益应用到虚拟机规模集,请使用以下命令之一:

# This will enable Azure Hybrid Benefit while creating a RHEL Virtual Machine Scale Set
az vmss create --name myVmName --resource-group myResourceGroup --orchestration-mode Uniform --vnet-name myVnet --subnet mySubnet  --image myRedHatImageURN --admin-username myAdminUserName --admin-password myPassword --instance-count myInstanceCount --license-type RHEL_BYOS 

# This will enable Azure Hybrid Benefit while creating a SLES Virtual Machine Scale Set
az vmss create --name myVmName --resource-group myResourceGroup --orchestration-mode Uniform --vnet-name myVnet --subnet mySubnet  --image myRedHatImageURN --admin-username myAdminUserName --admin-password myPassword --instance-count myInstanceCount --license-type SLES_BYOS

后续步骤