重要
若要使备用池成功创建和管理资源,需要访问订阅中的关联资源。 确保为备用池资源提供程序分配正确的权限,以便备用池正常运行。 有关详细说明,请参阅 为备用池配置角色权限。
可以随时更新实例的状态和备用池的最大就绪容量。 只能在备用池创建期间设置备用池名称。 如果要将预配状态更新为休眠状态,请确保将虚拟机规模集正确配置为使用休眠虚拟机。 有关详细信息,请参阅 休眠概述。
更改备用池的预配状态时,支持在以下状态之间进行转换。 不支持在“已停止”(已解除分配)状态和休眠状态之间进行转换。 如果使用“已停止”(已解除分配)池,而想要改用休眠池,请先过渡到正在运行的池,然后将预配状态更新为休眠状态。
| 初始状态 |
已更新状态 |
| 跑步 |
已停止(已解除分配) |
| 跑步 |
已休眠 |
| 已停止(已解除分配) |
跑步 |
| 已休眠 |
跑步 |
| 已休眠 |
已停止(已解除分配) |
更新备用池
注释
Azure 门户中尚未提供将备用池 VM 状态设置为休眠状态。 若要使用休眠的 VM 状态配置备用池,请使用备用 SDK,例如 CLI 或 PowerShell。
- 导航到与备用池关联的虚拟机规模集。
- 在“可用性 + 缩放”下,选择“备用池”。
- 选择“管理池”。
- 更新配置并保存任何更改。
使用 az standby-vm-pool update 更新现有备用池。
az standby-vm-pool update \
--resource-group myResourceGroup \
--name myStandbyPool \
--max-ready-capacity 20 \
--min-ready-capacity 5 \
--vm-state "Deallocated"
使用 Update-AzStandbyVMPool 更新现有备用池。
Update-AzStandbyVMPool `
-ResourceGroup myResourceGroup `
-Name myStandbyPool `
-MaxReadyCapacity 20 `
-MinReadyCapacity 5 `
-VMState "Deallocated"
更新现有的备用池部署。 使用 az deployment group create 或 New-AzResourceGroupDeployment 部署更新模板。
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "east us"
},
"name": {
"type": "string",
"defaultValue": "myStandbyPool"
},
"maxReadyCapacity" : {
"type": "int",
"defaultValue": 10
},
"minReadyCapacity" : {
"type": "int",
"defaultValue": 5
},
"virtualMachineState" : {
"type": "string",
"defaultValue": "Deallocated"
},
"attachedVirtualMachineScaleSetId" : {
"type": "string",
"defaultValue": "/subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/myScaleSet"
}
},
"resources": [
{
"type": "Microsoft.StandbyPool/standbyVirtualMachinePools",
"apiVersion": "2025-03-01",
"name": "[parameters('name')]",
"location": "[parameters('location')]",
"properties": {
"elasticityProfile": {
"maxReadyCapacity": "[parameters('maxReadyCapacity')]",
"minReadyCapacity": "[parameters('minReadyCapacity')]"
},
"virtualMachineState": "[parameters('virtualMachineState')]",
"attachedVirtualMachineScaleSetId": "[parameters('attachedVirtualMachineScaleSetId')]"
}
}
]
}
更新现有的备用池部署。 使用 az deployment group create 或 New-AzResourceGroupDeployment 部署更新模板。
param location string = resourceGroup().location
param standbyPoolName string = 'myStandbyPool'
param maxReadyCapacity int = 10
param minReadyCapacity int = 5
@allowed([
'Running'
'Deallocated'
'Hibernated'
])
param vmState string = 'Deallocated'
param virtualMachineScaleSetId string = '/subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/myScaleSet'
resource standbyPool 'Microsoft.standbypool/standbyvirtualmachinepools@2025-03-01' = {
name: standbyPoolName
location: location
properties: {
elasticityProfile: {
maxReadyCapacity: maxReadyCapacity
minReadyCapacity: minReadyCapacity
}
virtualMachineState: vmState
attachedVirtualMachineScaleSetId: virtualMachineScaleSetId
}
}
使用“创建或更新”更新现有备用池。
PUT https://management.azure.com/subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/myStandbyPool?api-version=2025-03-01
{
"type": "Microsoft.StandbyPool/standbyVirtualMachinePools",
"name": "myStandbyPool",
"location": "east us",
"properties": {
"elasticityProfile": {
"maxReadyCapacity": 20
"minReadyCapacity": 5
},
"virtualMachineState":"Deallocated",
"attachedVirtualMachineScaleSetId": "/subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/myScaleSet"
}
}
删除备用池
- 导航到与备用池关联的虚拟机规模集。
- 在“可用性 + 缩放”下,选择“备用池”。
- 选择“删除池”。
- 选择“删除”。
使用 az standbypool delete 删除现有备用池。
az standby-vm-pool delete \
--resource-group myResourceGroup \
--name myStandbyPool
使用 Remove-AzStandbyVMPool 删除现有备用池。
Remove-AzStandbyVMPool `
-ResourceGroup myResourceGroup `
-Name myStandbyPool `
-Nowait
使用 Delete 删除现有备用池。
DELETE https://management.azure.com/subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.StandbyPool/standbyVirtualMachinePools/myStandbyPool?api-version=2025-03-01
后续步骤
查看有关虚拟机规模集备用池的最常见问题解答。