0

我开发了一个包含多个组件的托管应用程序。现在,当我从服务目录部署应用程序时,所有组件都已成功部署,但Azure Monitor 部署除外。它在 403 上很糟糕,并以错误的网关代码结束。

当我将它部署为非托管应用程序时,所有组件都成功部署,没有任何错误。所以我知道模板是正确的。

当我删除失败的天蓝色警报并使用提供程序“Microsoft.Insights/metricAlert”向托管应用程序添加新的指标警报时,部署成功。

因此,我怀疑提供程序“Microsoft.Insights/scheduledQueryRules”未启用托管应用程序。(?)

任何人的想法?

这是我使用的模板:

 {
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "alertName": {
      "type": "string",
      "defaultValue": "",
      "metadata": {
        "description": "Name of the alert"
      }
    },
    "query": {
      "type": "string",
      "defaultValue": "",
      "metadata": {
        "description": "The log query to execute"
      }
    },
    "threshold": {
      "type": "int",
      "metadata": {
        "description": "The log query threshold"
      }
    },
    "alertDescription": {
      "type": "string",
      "defaultValue": "",
      "metadata": {
        "description": "The Alert description"
      }
    },
    "alertSeverity": {
      "type": "string",
      "defaultValue": "4",
      "metadata": {
        "description": "The Alert Severity 4 is the highest"
      }
    },
 
    "alertThresholdOperator": {
      "type": "string",
      "defaultValue": "",
      "metadata": {
        "description": ""
      }
    },
    "sourceId": {
      "type": "string",
      "defaultValue": "",
      "metadata": {
        "description": "Resource ID of the Log Analytics workspace."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "",
      "metadata": {
        "description": "Location for the alert. Must be the same location as the workspace."
      }
    },
    "actionGroupId": {
      "type": "string",
      "defaultValue": "",
      "metadata": {
        "description": "The ID of the action group that is triggered when the alert is activated."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.Insights/scheduledQueryRules",
      "name": "[parameters('alertName')]",
      "apiVersion": "2018-04-16",
      "location": "[parameters('location')]",
      "properties": {
        "description": "",
        "enabled": "true",
        "source": {
          "query": "[parameters('query')]",
          "dataSourceId": "[parameters('sourceId')]",
          "queryType": "ResultCount"
        },
        "schedule": {
          "frequencyInMinutes": 5,
          "timeWindowInMinutes": 5
        },
        "action": {
          "odata.type": "Microsoft.WindowsAzure.Management.Monitoring.Alerts.Models.Microsoft.AppInsights.Nexus.DataContracts.Resources.ScheduledQueryRules.AlertingAction",
          "severity": "[parameters('alertSeverity')]",
          "aznsAction": {
            "actionGroup": "[array(parameters('actionGroupId'))]",
            "emailSubject": "Alert mail"
          },
          "trigger": {
            "thresholdOperator": "[parameters('alertThresholdOperator')]",
            "threshold": "[parameters('threshold')]",
            "metricTrigger": {
              "thresholdOperator": "GreaterThan",
              "threshold": 0,
              "metricTriggerType": "Consecutive",
              "metricColumn": "Computer,CounterName,InstanceName"
            }
          }
        }
      }
    }
  ]
}

错误代码的一部分:

....
    "properties": {
            "statusCode": "BadGateway",
            "serviceRequestId": null,
            "statusMessage": "{\"error\":{\"code\":\"The remote server returned an error: (403) Forbidden.\",\"message\":{\"lang\":\"en-US\",\"value\":\"The remote server returned an error: (403) Forbidden.\"}}}",
            "eventCategory": "Administrative",
            "entity": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/mngapp-webapp-01032021094311/providers/Microsoft.Insights/scheduledQueryRules/morethan2requestpersecdetected",
            "message": "Microsoft.Insights/scheduledQueryRules/write",
            "hierarchy": "a06c42dd-f12b-4f1e-a454-0e7236d84790"
        },
....

谢谢,米歇尔

4

1 回答 1

0

"sourceId": { "type": "string", "defaultValue": "", "metadata": { "description": "Log Analytics 工作区的资源 ID。" } }

日志分析工作区是否与托管资源组位于不同的资源组中?

于 2021-01-08T22:35:21.247 回答