【Azure Cloud Service】创建Azure云服务时遇见分配VM资源错误: VM(s) with the following constraints cannot be allocated, because the condition is too restrictive - LuBu0505/My-Code GitHub Wiki

问题描述

创建Azure Cloud Service 资源,遇见资源操作完成时的终端预配状态为Failed的信息。

创建失败,创建的错误日志截图如下: image.png

 详细的错误信息为:

{

"code":"DeploymentFailed",

"message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.",

"details":[{"code":"OverconstrainedAllocationRequest","message":"Allocation failed. VM(s) with the following constraints cannot be allocated, because the condition is too restrictive. Please remove some constraints and try again. Constraints applied are:\n  - VM Size\n"}]}

问题解答

错误信息中,提示部署Cloud Service(云服务)时,所选择的VM Size(Standard_D4)被限制,分配失败。因为Cloud Service(云服务)所支持的VM Size在不同的区域会有所变动,需要先通过如下的PowerShell脚本来检索可以使用的VM Size List。

Powershell脚本:

   # Update the location
    $location = 'ChinaNorth3' # Get all Compute Resource Skus
    $allSkus = Get-AzComputeResourceSku # Filter virtualMachine skus for given location
    $vmSkus = $allSkus.Where{$_.resourceType -eq 'virtualMachines' -and $_.LocationInfo.Location -like $location} # From filtered virtualMachine skus, select PaaS Skus
    $passVMSkus = $vmSkus.Where{$_.Capabilities.Where{$_.name -eq 'VMDeploymentTypes'}.Value.Contains("PaaS")} # Optional step to format and sort the output by Family
    $passVMSkus | Sort-Object Family, Name | Format-Table -Property Family, Name, Size

执行结果: image.png

当把Standard_D4替换成 Standard_D4_v2后,创建Cloud Service(云服务)成功。

参考资料

配置云服务(外延支持)的大小 : https://docs.azure.cn/zh-cn/cloud-services-extended-support/available-sizes#configure-sizes-for-cloud-services-extended-support

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!