创建 alertRule

命名空间:microsoft.graph.deviceManagement

重要

Microsoft Graph 中版本下的 /beta API 可能会更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 在 v1.0 中是否可用,请使用 版本 选择器。

创建 alertRule 对象。

权限

调用此 API 需要以下权限之一。 若要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) CloudPC.ReadWrite.All
委派(个人 Microsoft 帐户) 不支持。
应用程序 CloudPC.ReadWrite.All

HTTP 请求

POST /deviceManagement/monitoring/alertRules

请求标头

名称 说明
Authorization 持有者 {token}。 必填。
Content-Type application/json. 必需。

请求正文

在请求正文中,提供应更新的属性的值。 请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。

下表指定可更新的属性。

属性 类型 说明
alertRuleTemplate alertRuleTemplate 警报事件的规则模板。 可能的值包括 cloudPcProvisionScenariocloudPcImageUploadScenariocloudPcOnPremiseNetworkConnectionCheckScenariounknownFutureValue
说明 String 规则说明。
displayName String 规则的显示名称。
enabled Boolean 指示规则是启用还是禁用的规则的状态。 如果 true为 ,则启用规则;否则禁用该规则。
isSystemRule Boolean 指示规则是否为系统规则。 如果 true为 ,则规则是系统规则;否则,该规则是自定义定义的规则,可以编辑。 系统规则是内置的,只能编辑几个属性。
notificationChannels microsoft.graph.deviceManagement.notificationChannel 集合 用户选择的规则的通知通道。
severity ruleSeverityType 规则的严重性。 可能的值包括 unknowninformationalwarningcriticalunknownFutureValue
阈 值 microsoft.graph.deviceManagement.ruleThreshold 规则的阈值。

响应

如果成功,此方法在 201 Created 响应正文中返回响应代码和 microsoft.graph.deviceManagement.alertRule 对象。

示例

请求

请求示例如下所示。

POST https://graph.microsoft.com/beta/deviceManagement/monitoring/alertRules
Content-Type: application/json

{
  "id": "215c55cc-b1c9-4d36-a870-be5778101714",
  "displayName": "Azure network connection failure impacting Cloud PCs",
  "severity": "informational",
  "isSystemRule": true,
  "description": "Azure network connection checks have failed and is potentially impacting existing Cloud PCs and blocking the provisioning of new Cloud PCs",
  "enabled": true,
  "alertRuleTemplate": "cloudPcOnPremiseNetworkConnectionCheckScenario",
  "threshold": {
      "aggregation": "count",
      "operator": "greaterOrEqual",
      "target": 90
  },
  "notificationChannels": [
      {
        "notificationChannelType": "portal",
        "receivers": [
            ""
        ],
        "notificationReceivers": []
      },
      {
        "notificationChannelType": "email",
        "receivers": [
            "serena.davis@contoso.com"
        ],
        "notificationReceivers": [
            {
                "locale": "en-us",
                "contactInformation": "serena.davis@contoso.com"
            }
        ]
      }
  ]
}

响应

下面展示了示例响应。

HTTP/1.1 201 CREATED
Content-Type: application/json

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#deviceManagement/monitoring/alertRules/$entity",
  "id": "215c55cc-b1c9-4d36-a870-be5778101714",
  "displayName": "Azure network connection failure impacting Cloud PCs",
  "severity": "informational",
  "isSystemRule": true,
  "description": "Azure network connection checks have failed and is potentially impacting existing Cloud PCs and blocking the provisioning of new Cloud PCs",
  "enabled": true,
  "alertRuleTemplate": "cloudPcOnPremiseNetworkConnectionCheckScenario",
  "threshold": {
      "aggregation": "count",
      "operator": "greaterOrEqual",
      "target": 90
  },
  "notificationChannels": [
      {
        "notificationChannelType": "portal",
        "receivers": [
            ""
        ],
        "notificationReceivers": []
      },
      {
        "notificationChannelType": "email",
        "receivers": [
            "serena.davis@contoso.com"
        ],
        "notificationReceivers": [
            {
                "locale": "en-us",
                "contactInformation": "serena.davis@contoso.com"
            }
        ]
      }
  ]
}