使用 Azure 门户创建虚拟机规模集
本文将详细介绍如何使用 Azure CLI 创建虚拟机规模集。
确保已安装最新的 Azure CLI,并且已使用 az login 登录到 Azure 帐户。
创建资源组
使用 az group create 创建资源组,如下所示:
az group create --name myResourceGroup --location chinanorth2
创建虚拟机规模集
重要
从 2023 年 11 月开始,使用 PowerShell 和 Azure CLI 创建的 VM 规模集将默认为灵活业务流程模式(如果未指定业务流程模式)。 若要详细了解此更改以及你应采取哪些操作,请访问针对 VMSS PowerShell/CLI 客户的中断性变更 - Microsoft 社区中心
现在,使用 az vmss create 创建虚拟机规模集。 以下示例创建实例计数为 2 的规模集,并生成 SSH 密钥。
az vmss create \
--resource-group myResourceGroup \
--name myScaleSet \
--orchestration-mode Flexible \
--image <SKU Linux Image> \
--instance-count 2 \
--admin-username azureuser \
--generate-ssh-keys
清理资源
若要删除规模集和其他资源,请使用 az group delete 删除资源组及其所有资源。 --no-wait
参数会使光标返回提示符处,无需等待操作完成。 使用 --yes
参数将确认你希望删除资源,不会再通过其他提示进行询问。
az group delete --name myResourceGroup --yes --no-wait