部署多个azure应用服务计划会导致错误"具有指定名称的Web空间已存在"

时间:2016-03-18 09:34:24

标签: azure-web-sites azure-resource-manager

如何在同一天蓝色资源组项目中部署多个应用服务计划?

当我尝试在模板中部署两个带有以下资源部分的Web应用程序时:

"resources": [
  {
    "name": "[parameters('Plan1Name')]",
    "type": "Microsoft.Web/serverfarms",
    "location": "[resourceGroup().location]",
    "apiVersion": "2014-06-01",
    "dependsOn": [ ],
    "tags": {
      "displayName": "Plan1"
    },
    "properties": {
      "name": "[parameters('Plan1Name')]",
      "sku": "[parameters('Plan1SKU')]",
      "workerSize": "[parameters('Plan1WorkerSize')]",
      "numberOfWorkers": 1
    }
  },
  {
    "name": "[parameters('Plan2Name')]",
    "type": "Microsoft.Web/serverfarms",
    "location": "[resourceGroup().location]",
    "apiVersion": "2014-06-01",
    "dependsOn": [
    ],
    "tags": {
      "displayName": "Plan2"
    },
    "properties": {
      "name": "[parameters('Plan2Name')]",
      "sku": "[parameters('Plan2SKU')]",
      "workerSize": "[parameters('Plan2WorkerSize')]",
      "numberOfWorkers": 1
    }
  }
],

部署时出现以下错误:

[VERBOSE] 09:26:11 - Create template deployment 'azuredeploy-0318-0926'.
[ERROR] New-AzureRmResourceGroupDeployment : 09:26:16 - Resource 
[ERROR] Microsoft.Web/serverfarms 'Plan1' failed with message 'Web space with 
[ERROR] specified name already exists.'
[ERROR] At C:\dev\src\vs2015\projects\webappplandeploy\webappplandeploy\Scripts\Deploy-
[ERROR] AzureResourceGroup.ps1:98 char:1
[ERROR] + New-AzureRmResourceGroupDeployment -Name ((Get-ChildItem $TemplateFil ...
[ERROR] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ERROR]     + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeplo 
[ERROR]    yment], Exception
[ERROR]     + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResou 
[ERROR]    rceGroupDeploymentCommand
[ERROR]  
[VERBOSE] 09:26:18 - Resource Microsoft.Web/serverfarms 'Plan2' provisioning status is succeeded

1 个答案:

答案 0 :(得分:4)

我需要将此行添加到计划2中:

"dependsOn": [
      "[concat('Microsoft.Web/serverfarms/', parameters('Plan1Name'))]"
],

在我研究解决这个问题的过程中,我发现应用服务计划似乎无法同时处理多个应用服务计划。为了使其正常工作,我需要在所有其他应用服务计划上添加依赖关系,以便它们一个接一个地链接。

  {
    "name": "[parameters('Plan2Name')]",
    "type": "Microsoft.Web/serverfarms",
    "location": "[resourceGroup().location]",
    "apiVersion": "2014-06-01",
    "dependsOn": [
      "[concat('Microsoft.Web/serverfarms/', parameters('Plan1Name'))]"
    ],
    "tags": {
      "displayName": "Plan2"
    },
    "properties": {
      "name": "[parameters('Plan2Name')]",
      "sku": "[parameters('Plan2SKU')]",
      "workerSize": "[parameters('Plan2WorkerSize')]",
      "numberOfWorkers": 1
    }
  }

我得到了这个输出:

[VERBOSE] 09:32:07 - Create template deployment 'azuredeploy-0318-0932'.
[VERBOSE] 09:32:11 - Resource Microsoft.Web/serverfarms 'Plan1' provisioning status is succeeded
[VERBOSE] 09:32:14 - Resource Microsoft.Web/serverfarms 'Plan2' provisioning status is succeeded