使用ARM模板部署网站和App Insights,但将App Insights放在另一个资源组中

时间:2016-11-15 03:01:46

标签: azure azure-resource-manager

我有一个简单的ARM模板:

{
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
        "hostingPlanName": {
          "type": "string",
          "minLength": 1
        },
        "WebsiteName": {
          "type": "string",
          "minLength": 1
        },
        "externalResourceGroupName": {
          "type": "string",
          "metadata": {
            "description": "The name of a resource group if the deployment need to deploy to an RG that is not the current RG."
          }
        }
      },
      "variables": {
      },
      "resources": [
        {
          "apiVersion": "2015-08-01",
          "name": "[parameters('webSiteName')]",
          "type": "Microsoft.Web/sites",
          "kind": "api",
          "location": "[resourceGroup().location]",
          "tags": {
            "displayName": "Website"
          },
          "dependsOn": [
          ],
          "properties": {
            "name": "[parameters('webSiteName')]",
            "serverFarmId": "[resourceId(parameters('externalResourceGroupName'), 'microsoft.web/serverfarms/', parameters('hostingPlanName'))]",
            "siteConfig": {
              "use32BitWorkerProcess": "false",
              "AlwaysOn": true,
              "phpVersion": "Off"
            },
            "clientAffinityEnabled": false
          },
          "resources": [
          ]
        },
        {
          "name": "[parameters('webSiteName')]",
          "type": "Microsoft.Insights/components",
          "location": "Central US",
          "apiVersion": "2014-04-01",
          "dependsOn": [
            "[concat('Microsoft.Web/sites/', parameters('webSiteName'))]"
          ],
          "tags": {
            "displayName": "[parameters('webSiteName')]"
          },
          "properties": {
            "applicationId": "[parameters('webSiteName')]"
          }
        }
      ]
    }

您可以在App Insights中看到以下资源: 的 Microsoft.Insights /组件

问题是,我想使用此单一模板部署网站和应用洞察,但我想指定将应用洞察资源部署到网站的其他资源组。

例如

  • 网站资源组 - rgWebSite
  • App洞察资源组 - rgAppInsights

您会注意到我的网站将其应用服务计划(ServerFarmId)设置为另一个资源组中的应用服务计划,因此应该可以通过应用洞察进行相同的操作。

0 个答案:

没有答案