azure-web-app-service - 部署多个 azure 应用服务计划导致错误 "Web space with specified name already exists"

标签 azure-web-app-service azure-resource-manager

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

当我尝试使用模板中的以下资源部分部署两个 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

最佳答案

我需要将此行添加到计划 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

关于azure-web-app-service - 部署多个 azure 应用服务计划导致错误 "Web space with specified name already exists",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36080794/

相关文章:

Azure Web应用程序未更新keyvault上的证书

azure - 部署后清理包文件夹

azure - 引用ARM模板中的VSTS构建/发布变量

azure - 如何通过 azure Devops 管道运行 AzureRM 脚本

visual-studio - VS 2015 Azure 发布向导不处理 ARM 创建的资源吗?

.net - 为什么 Azure 应用服务找不到我的 GoDaddy 证书?

sendgrid - 使用SendGrid发送电子邮件-本地ok,远程ok

azure - 从应用服务安全访问 CosmosDB

azure - 在 Bicep 模块中创建时获取 Function App 默认主机 key

azure - 具有 "Contributor"和 "User Access Administrator"角色的用户与具有 "Owner"角色的用户相同吗?