将云服务(经典)部署到 Azure 时对 ConstrainedAllocationFailed 进行故障排除Troubleshoot ConstrainedAllocationFailed when deploying a Cloud service (classic) to Azure

在本文中,你将解决由于分配约束而无法部署 Azure 云服务(经典)的分配失败。In this article, you'll troubleshoot allocation failures where Azure Cloud services (classic) can't deploy because of allocation constraints.

将实例部署到云服务(经典)或者添加新的 Web 角色或辅助角色实例时,Azure 会分配计算资源。When you deploy instances to a Cloud service (classic) or add new web or worker role instances, Azure allocates compute resources.

在执行这些操作时,甚至在达到 Azure 订阅限制之前,有时可能会收到错误。You may occasionally receive errors during these operations even before you reach the Azure subscription limit.

提示

规划服务的部署时,本信息可能也有用。The information may also be useful when you plan the deployment of your services.

症状Symptom

在 Azure 门户中,导航到云服务(经典),并在侧栏中选择“操作日志(经典)”来查看日志。In Azure portal, navigate to your Cloud service (classic) and in the sidebar select Operation log (classic) to view the logs.

该图显示了“操作日志(经典)”边栏选项卡。

检查云服务(经典)的日志时,你将看到以下异常:When you're inspecting the logs of your Cloud service (classic), you'll see the following exception:

异常类型Exception Type 错误消息Error Message
ConstrainedAllocationFailedConstrainedAllocationFailed Azure 操作“{Operation ID}”失败,代码为 Compute.ConstrainedAllocationFailed。Azure operation '{Operation ID}' failed with code Compute.ConstrainedAllocationFailed. 详细信息:分配失败;无法满足请求中的约束。Details: Allocation failed; unable to satisfy constraints in request. 请求的新服务部署绑定至地缘组,或以虚拟网络为目标,或此托管服务下已经有部署。The requested new service deployment is bound to an Affinity Group, or it targets a Virtual Network, or there is an existing deployment under this hosted service. 上述任一情况都会将新的部署局限于特定的 Azure 资源。Any of these conditions constrains the new deployment to specific Azure resources. 请稍后重试,或尝试减小 VM 大小或角色实例数目。Retry later or try reducing the VM size or number of role instances. 或者,可能的话,删除先前提到的约束,或尝试部署到不同的区域。Alternatively, if possible, remove the aforementioned constraints or try deploying to a different region.

原因Cause

将第一个实例部署到云服务时(不管是部署到过渡环境还是生产环境),都会将该云服务固定到某个群集。When the first instance is deployed to a Cloud service (in either staging or production), that Cloud service gets pinned to a cluster.

随着时间的推移,此群集中的资源可能会被完全利用。Over time, the resources in this cluster may become fully utilized. 当固定的群集中没有足够的资源可用时,如果云服务(经典)发出分配请求来请求更多资源,则该请求将导致分配失败。If a Cloud service (classic) makes an allocation request for more resources when insufficient resources are available in the pinned cluster, the request will result in an allocation failure. 有关详细信息,请参阅分配失败的常见问题For more information, see the allocation failure common issues.

解决方案Solution

将现有的云服务固定到群集。Existing cloud services are pinned to a cluster. 云服务(经典)的任何进一步部署都会发生在同一个群集中。Any further deployments for the Cloud service (classic) will happen in the same cluster.

在这种情况下遇到分配错误时,建议的操作过程是重新部署到新的云服务(经典)(并更新 CNAME)。When you experience an allocation error in this scenario, the recommended course of action is to redeploy to a new Cloud service (classic) (and update the CNAME).

提示

这种解决方案可能会最成功,因为它允许平台从该区域的所有群集中进行选择。This solution is likely to be most successful as it allows the platform to choose from all clusters in that region.

备注

此解决方案应该不会导致停机。This solution should incur zero downtime.

  1. 将工作负载部署到新的云服务(经典)。Deploy the workload to a new Cloud service (classic).

    警告

    如果你不希望丢失与此部署槽位关联的 IP 地址,则可以使用解决方案 3 - 保留 IP 地址If you do not want to lose the IP address associated with this deployment slot, you can use Solution 3 - Keep the IP address.

  2. 更新 CNAME 或 A 记录,以将流量指向新的云服务(经典)。Update the CNAME or A record to point traffic to the new Cloud service (classic).

  3. 一旦零流量流向旧站点,就可以删除旧的云服务(经典)。Once zero traffic is going to the old site, you can delete the old Cloud service (classic).

如需更多修正步骤,请参阅排查云服务(经典)分配失败 | Microsoft DocsSee Troubleshooting Cloud service (classic) allocation failures | Microsoft Docs for further remediation steps.

后续步骤Next steps

有关更多分配失败解决方案和背景信息:For more allocation failure solutions and background information:

如果你有本文未解决的 Azure 问题,请访问 MSDN 和 Stack Overflow 上的 Azure 论坛。If your Azure issue isn't addressed in this article, visit the Azure forums on MSDN and Stack Overflow. 可以在这些论坛上发布问题。You can post your issue in these forums. 还可提交 Azure 支持请求。You also can submit an Azure support request. 若要提交支持请求,请在 Azure 支持页上,选择“获取支持”。To submit a support request, on the Azure support page, select Get support.