Deploying a website and App Insights with an ARM template but putting App Insights in another resource group

北战南征 提交于 2019-12-11 06:33:18

问题


I have a simple ARM template:

{
      "$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')]"
          }
        }
      ]
    }

You can see the following resource for App Insights: Microsoft.Insights/components

The thing is, I want to deploy the website and app insights with this single template but I want to specify that the app insights resource get deployed to a different resource group to the web site.

For example

  • Website resource group - rgWebSite
  • App insights resource group - rgAppInsights

You will note that my website sets its App Service Plan (ServerFarmId) to be one that is in another resource group so the same should be possible with app insights.

来源:https://stackoverflow.com/questions/40601329/deploying-a-website-and-app-insights-with-an-arm-template-but-putting-app-insigh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!