【问题标题】:Assign Web App to an existing service plan in ARM template将 Web 应用程序分配给 ARM 模板中的现有服务计划
【发布时间】:2020-07-21 19:35:01
【问题描述】:

我正在尝试将现有服务计划附加到 Azure 资源管理器模板中的新 Web 应用程序。服务计划已经启动并运行,而不是该 arm 模板的一部分

【问题讨论】:

    标签: azure azure-resource-manager


    【解决方案1】:

    你现在可能已经想通了,但是如果其他人像我一样点击这个帖子,我会发布这个。

    您可以使用resourceId function 引用现有的服务计划。

    然后只需在模板中serverFarmId 的属性中使用它即可。

     "properties": {
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
      }
    

    所以基本上正是飞汉示例显示的内容,但您需要删除 dependsOn(当然还有服务计划资源)。

    【讨论】:

      【解决方案2】:

      我的服务计划在不同的资源组中,所以我还必须提供 RG 名称

      "serverFarmId": "[resourceId('plangroup', 'Microsoft.Web/serverfarms', 参数('hostingPlanName'))]"

      Source

      【讨论】:

        【解决方案3】:

        我正在尝试将 Web 服务计划附加到 Auzre 资源管理器模板中的新 Web 应用程序。服务计划不是由同一个模板创建的

        你说没有创建服务计划,不是现有的服务计划吗?如果您想通过带有资源管理器模板的 Azure PowerShell 将应用服务计划和 Web 应用部署到 Azure,请参考以下 ARM 模板。

        {
          "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {
            "hostingPlanName": {
              "type": "string",
              "minLength": 1
            },
            "skuName": {
              "type": "string",
              "defaultValue": "F1",
              "allowedValues": [
                "F1",
                "D1",
                "B1",
                "B2",
                "B3",
                "S1",
                "S2",
                "S3",
                "P1",
                "P2",
                "P3",
                "P4"
              ],
              "metadata": {
                "description": "Describes plan's pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/"
              }
            },
            "skuCapacity": {
              "type": "int",
              "defaultValue": 1,
              "minValue": 1,
              "metadata": {
                "description": "Describes plan's instance count"
              }
            },
            "webSiteName": {
              "type": "string",
              "minLength": 1
            }
          },
          "resources": [
            {
              "apiVersion": "2015-08-01",
              "name": "[parameters('hostingPlanName')]",
              "type": "Microsoft.Web/serverfarms",
              "location": "[resourceGroup().location]",
              "tags": {
                "displayName": "HostingPlan"
              },
              "sku": {
                "name": "[parameters('skuName')]",
                "capacity": "[parameters('skuCapacity')]"
              },
              "properties": {
                "name": "[parameters('hostingPlanName')]"
              }
            },
            {
              "apiVersion": "2015-08-01",
              "name": "[parameters('webSiteName')]",
              "type": "Microsoft.Web/sites",
              "location": "[resourceGroup().location]",
              "tags": {
                "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
                "displayName": "Website"
              },
              "dependsOn": [
                "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
              ],
              "properties": {
                "name": "[parameters('webSiteName')]",
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]"
              }
            }
          ]
        }
        

        【讨论】:

        • 对不起,我改写了。请检查
        猜你喜欢
        • 2020-11-10
        • 1970-01-01
        • 1970-01-01
        • 2020-11-14
        • 1970-01-01
        • 2020-07-10
        • 2017-08-07
        • 2022-10-04
        • 2017-07-07
        相关资源
        最近更新 更多