Deploying a website and App Insights using an ARM template, but including App Insights in a different resource group

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: <Strong> Microsoft.Insights / components

The fact is that I want to expand the presentation of the website and the application using this single template, but I want to indicate that the application search resource is deployed to another group of resources on the website.

for instance

  • Site Resource Group - rgWebSite
  • Application Resource Group - rgAppInsights

You will notice that my site sets its application service plan (ServerFarmId) as one that is in a different resource group, so the same should be possible when using applications.

0

Source: https://habr.com/ru/post/1668724/


All Articles