在应用服务计划之间移动 Azure 网站

Move Azure website between App Service Plans

是否可以将 Azure 网站 移动到不同的(或新的)应用服务计划

我已经尝试过旧门户和新门户,但找不到适合它的选项。

是的,您可以从 Azure 门户中的 Web 应用程序 blade 执行此操作。您必须展开工具栏才能看到该选项。见下文。

我需要在不同的订阅之间移动内容,根据文档,这是很有可能的。很多都是无耻地从 azure website 复制过来的。该解决方案利用了 Azure Powershell 1.0。

首先,如果您需要移动 Web 应用程序并且它已连接 webfarm,则有一些 limitations:

You can move Azure Web App resources using the ARM Move Resources Api.

Azure Web Apps currently supports the following move scenarios:

  • Moving the entire contents of a resource group (web apps, app service plans, and certificates) to another resource group.
    • Note: The destination resource group can not contain any Microsoft.Web resources in this scenario
  • Moving individual web apps to a different resource group, while still hosting them in their current app service plan (the app service plan stays in the old resource group)

基本上,您需要从要移动的资源中获取资源 ID,然后使用 Move-AzureRmResource 命令。您自然需要一个能够读取和写入所涉及订阅的 Azure 登录名。

$webapp = Get-AzureRmResource -ResourceGroupName OldGroup -ResourceName WebApp -ResourceType Microsoft.Web/sites

$plan = Get-AzureRmResource -ResourceGroupName OldGroup -ResourceName Plan -ResourceType Microsoft.Web/serverFarms

移动-AzureRmResource -DestinationResourceGroupName NewGroup -ResourceId ($webapp.ResourceId, $plan.ResourceId) -DestinationSubscriptionId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

我要指出,如果您要将资源移动到另一个订阅,则需要注意一些事项。首先,该订阅必须有权在该地区提供网站,API 超出此范围,但只需创建一个网站并将其删除即可为订阅提供这些权利。就我而言,我遇到了第二个错误,该错误仍未解决,但我怀疑与正在移动的资源相关的其他资源是罪魁祸首。如果我解决了问题,将更新更多信息。

最后一点,也可以使用 REST API

最初接受的答案已有一年多了。在 Azure 世界中,那是永恒。 Azure 门户中的 "Change App Plan" 按钮不再出现(截至 2016 年 6 月 17 日),所以我输入了我需要使用的 Powershell 命令,以便将 Web 应用程序移动到另一个应用程序服务计划。

Set-AzureRmWebApp -Name <webapp name> -ResourceGroupName <resource group name> -AppServicePlan <new app service plan>
Set-AzureRmWebAppSlot -Name <webapp name> -Slot <slot name> -ResourceGroupName <resource group name> -AppServicePlan <new app service plan>

选项“更改应用服务计划”已移至应用服务计划菜单。