Deploying a website and App Insights with an ARM t

2019-07-25 06:50发布

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.

0条回答
登录 后发表回答