用于配置诊断设置的 Azure 网关 ARM 模板(Log Analytics 工作区)

Azure Gateway ARM template to configure diagnostic setting (Log Analytics workspace)

我正在寻找有助于配置 (Log Analytics) 诊断设置的 ARM 模板。搜索了几个模板但没有希望。通过导出模板和资源浏览器尝试未找到诊断设置配置。请分享您的想法

这是我正在尝试的 ARM 模板

"apiVersion": "2015-07-01",
         "name": "[concat(parameters('applicationGateways_name'), '/Microsoft.Insights/service')]",
         "type": "Microsoft.Network/applicationGateways/providers/diagnosticsettings",
         "location": "[resourceGroup().location]",
          "dependsOn": [
            "[concat('Microsoft.Network/ApplicationGateways/', parameters('applicationGateways_name'))]"
          ],
          "properties":{
            "name":"DiagService",
            "workspaceId":"[variables('workspaceId')]",
            "logs":[
               {

其中"type":"Microsoft.Network/applicationGateways/providers/diagnosticsettings"不扣除

我正在尝试在现有工作区中添加

ARM 模板缺少要发送到工作区的 logs/metrics 类型。尝试将此添加到您的部分:

   "logs": [
      {
        "category": "ApplicationGatewayAccessLog",
        "enabled": true,
        "retentionPolicy": {
          "enabled": false,
          "days": 0
        }
      },
      {
        "category": "ApplicationGatewayPerformanceLog",
        "enabled": true,
        "retentionPolicy": {
          "enabled": false,
          "days": 0
        }
      },
      {
        "category": "ApplicationGatewayFirewallLog",
        "enabled": true,
        "retentionPolicy": {
          "enabled": false,
          "days": 0
        }
      }
    ],
    "metrics": [
      {
        "category": "AllMetrics",
        "timeGrain": "PT1M",
        "enabled": true,
        "retentionPolicy": {
          "enabled": false,
          "days": 0
        }

      }
    ]

根据需要编辑保留。

它适用于以下更改

{
   "apiVersion": "2017-05-01-preview",
   "name": "[concat(parameters('applicationGatewayName'), '/Microsoft.Insights/diagnosticSettings')]",
   "type":"Microsoft.Network/applicationGateways/providers/diagnosticSettings",
   "location": "[resourceGroup().location]",
   "dependsOn": [
        "[concat('Microsoft.Network/ApplicationGateways/', parameters('applicationGatewayName'))]"
      ],
      "properties":{
        "name":"Diag",
        "workspaceId":  "[concat('/subscriptions/', subscription().subscriptionId,  '/resourceGroups/', resourceGroup().name, '/providers/microsoft.operationalinsights/workspaces/', parameters('workspaceId'))]",


        "logs":[
           {
             "category": "ApplicationGatewayAccessLog",
             "enabled": true,
             "retentionPolicy": {
             "enabled": false,
             "days": 0
                                }
           },
           {
              "category": "ApplicationGatewayPerformanceLog",
              "enabled": true,
              "retentionPolicy": {
                "days": 0,
                "enabled": false
              }
            },
            {
              "category": "ApplicationGatewayFirewallLog",
              "enabled": true,
              "retentionPolicy": {
                "days": 0,
                "enabled": false
              }
            }
                ],
                "metrics": [
            {
              "category": "AllMetrics",
              "enabled": true,
              "retentionPolicy": {
                "enabled": false,
                "days": 0
              }
            }
          ]
                    }
  }

请注意这里我使用了之前创建的公共工作区