Пространство имен: microsoft.graph.deviceManagement
Важно!
API версии /beta в Microsoft Graph могут быть изменены. Использование этих API в производственных приложениях не поддерживается. Чтобы определить, доступен ли API в версии 1.0, используйте селектор версий.
Выберите разрешение или разрешения, помеченные как наименее привилегированные для этого API. Используйте более привилегированное разрешение или разрешения только в том случае, если это требуется приложению. Дополнительные сведения о делегированных разрешениях и разрешениях приложений см. в разделе Типы разрешений. Дополнительные сведения об этих разрешениях см. в справочнике по разрешениям.
Тип разрешения
Разрешения с наименьшими привилегиями
Более высокие привилегированные разрешения
Делегированные (рабочая или учебная учетная запись)
Укажите в тексте запроса только значения обновляемых свойств. Существующие свойства, которые не включены в текст запроса, сохраняют свои предыдущие значения или пересчитываются на основе изменений других значений свойств.
В следующей таблице указаны свойства, которые можно обновить.
Шаблон правила события оповещения. Допустимые значения: cloudPcProvisionScenario, cloudPcImageUploadScenario, cloudPcOnPremiseNetworkConnectionCheckScenario, cloudPcInGracePeriodScenario, cloudPcFrontlineInsufficientLicensesScenario, cloudPcInaccessibleScenario. Чтобы получить следующие значения из этого развиваемого перечисленияPrefer: include-unknown-enum-members, необходимо использовать заголовок запроса: cloudPcInGracePeriodScenario.
description
String
Описание правила.
displayName
String
Отображаемое имя правила.
включено
Логический
Состояние правила, указывающее, включено или отключено правило. Если trueзадано значение , правило включено; в противном случае правило будет отключено.
isSystemRule
Логический
Значение типа , указывающее, является ли правило системным. Если trueзадано значение , это правило является системным правилом; в противном случае это пользовательское правило, которое можно изменить. Во встроенных системных правилах можно изменить только несколько свойств.
Условия правила. Условия определяют, когда следует отправлять оповещение. Например, можно задать условие, чтобы оповещение отправлялось в случае сбоя подготовки шести или более облачных компьютеров.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models.DeviceManagement;
var requestBody = new AlertRule
{
Id = "215c55cc-b1c9-4d36-a870-be5778101714",
DisplayName = "Azure network connection failure impacting Cloud PCs",
Severity = RuleSeverityType.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 = AlertRuleTemplate.CloudPcOnPremiseNetworkConnectionCheckScenario,
Threshold = new RuleThreshold
{
Aggregation = AggregationType.Count,
Operator = OperatorType.GreaterOrEqual,
Target = 90,
},
Conditions = new List<RuleCondition>
{
new RuleCondition
{
RelationshipType = RelationshipType.Or,
ConditionCategory = ConditionCategory.AzureNetworkConnectionCheckFailures,
Aggregation = AggregationType.Count,
Operator = OperatorType.GreaterOrEqual,
ThresholdValue = "90",
},
},
NotificationChannels = new List<NotificationChannel>
{
new NotificationChannel
{
NotificationChannelType = NotificationChannelType.Portal,
NotificationReceivers = new List<NotificationReceiver>
{
},
},
new NotificationChannel
{
NotificationChannelType = NotificationChannelType.Email,
NotificationReceivers = new List<NotificationReceiver>
{
new NotificationReceiver
{
Locale = "en-us",
ContactInformation = "serena.davis@contoso.com",
},
},
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.DeviceManagement.Monitoring.AlertRules.PostAsync(requestBody);
Важно!
Пакеты SDK для Microsoft Graph по умолчанию используют версию API версии 1.0 и поддерживают не все типы, свойства и API, доступные в бета-версии. Дополнительные сведения о доступе к бета-API с помощью SDK см. в статье Использование пакетов Microsoft Graph SDK с бета-API.
// THE CLI IS IN PREVIEW. NON-PRODUCTION USE ONLY
mgc-beta device-management monitoring alert-rules create --body '{\
"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\
},\
"conditions": [\
{\
"relationshipType": "or",\
"conditionCategory": "azureNetworkConnectionCheckFailures",\
"aggregation": "count",\
"operator": "greaterOrEqual",\
"thresholdValue": "90"\
}\
],\
"notificationChannels": [\
{\
"notificationChannelType": "portal",\
"notificationReceivers": []\
},\
{\
"notificationChannelType": "email",\
"notificationReceivers": [\
{\
"locale": "en-us",\
"contactInformation": "serena.davis@contoso.com"\
}\
]\
}\
]\
}\
'
Важно!
Пакеты SDK для Microsoft Graph по умолчанию используют версию API версии 1.0 и поддерживают не все типы, свойства и API, доступные в бета-версии. Дополнительные сведения о доступе к бета-API с помощью SDK см. в статье Использование пакетов Microsoft Graph SDK с бета-API.
Пакеты SDK для Microsoft Graph по умолчанию используют версию API версии 1.0 и поддерживают не все типы, свойства и API, доступные в бета-версии. Дополнительные сведения о доступе к бета-API с помощью SDK см. в статье Использование пакетов Microsoft Graph SDK с бета-API.
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
com.microsoft.graph.beta.models.devicemanagement.AlertRule alertRule = new com.microsoft.graph.beta.models.devicemanagement.AlertRule();
alertRule.setId("215c55cc-b1c9-4d36-a870-be5778101714");
alertRule.setDisplayName("Azure network connection failure impacting Cloud PCs");
alertRule.setSeverity(com.microsoft.graph.beta.models.devicemanagement.RuleSeverityType.Informational);
alertRule.setIsSystemRule(true);
alertRule.setDescription("Azure network connection checks have failed and is potentially impacting existing Cloud PCs and blocking the provisioning of new Cloud PCs");
alertRule.setEnabled(true);
alertRule.setAlertRuleTemplate(com.microsoft.graph.beta.models.devicemanagement.AlertRuleTemplate.CloudPcOnPremiseNetworkConnectionCheckScenario);
com.microsoft.graph.beta.models.devicemanagement.RuleThreshold threshold = new com.microsoft.graph.beta.models.devicemanagement.RuleThreshold();
threshold.setAggregation(com.microsoft.graph.beta.models.devicemanagement.AggregationType.Count);
threshold.setOperator(com.microsoft.graph.beta.models.devicemanagement.OperatorType.GreaterOrEqual);
threshold.setTarget(90);
alertRule.setThreshold(threshold);
LinkedList<com.microsoft.graph.beta.models.devicemanagement.RuleCondition> conditions = new LinkedList<com.microsoft.graph.beta.models.devicemanagement.RuleCondition>();
com.microsoft.graph.beta.models.devicemanagement.RuleCondition ruleCondition = new com.microsoft.graph.beta.models.devicemanagement.RuleCondition();
ruleCondition.setRelationshipType(com.microsoft.graph.beta.models.devicemanagement.RelationshipType.Or);
ruleCondition.setConditionCategory(com.microsoft.graph.beta.models.devicemanagement.ConditionCategory.AzureNetworkConnectionCheckFailures);
ruleCondition.setAggregation(com.microsoft.graph.beta.models.devicemanagement.AggregationType.Count);
ruleCondition.setOperator(com.microsoft.graph.beta.models.devicemanagement.OperatorType.GreaterOrEqual);
ruleCondition.setThresholdValue("90");
conditions.add(ruleCondition);
alertRule.setConditions(conditions);
LinkedList<com.microsoft.graph.beta.models.devicemanagement.NotificationChannel> notificationChannels = new LinkedList<com.microsoft.graph.beta.models.devicemanagement.NotificationChannel>();
com.microsoft.graph.beta.models.devicemanagement.NotificationChannel notificationChannel = new com.microsoft.graph.beta.models.devicemanagement.NotificationChannel();
notificationChannel.setNotificationChannelType(com.microsoft.graph.beta.models.devicemanagement.NotificationChannelType.Portal);
LinkedList<com.microsoft.graph.beta.models.devicemanagement.NotificationReceiver> notificationReceivers = new LinkedList<com.microsoft.graph.beta.models.devicemanagement.NotificationReceiver>();
notificationChannel.setNotificationReceivers(notificationReceivers);
notificationChannels.add(notificationChannel);
com.microsoft.graph.beta.models.devicemanagement.NotificationChannel notificationChannel1 = new com.microsoft.graph.beta.models.devicemanagement.NotificationChannel();
notificationChannel1.setNotificationChannelType(com.microsoft.graph.beta.models.devicemanagement.NotificationChannelType.Email);
LinkedList<com.microsoft.graph.beta.models.devicemanagement.NotificationReceiver> notificationReceivers1 = new LinkedList<com.microsoft.graph.beta.models.devicemanagement.NotificationReceiver>();
com.microsoft.graph.beta.models.devicemanagement.NotificationReceiver notificationReceiver = new com.microsoft.graph.beta.models.devicemanagement.NotificationReceiver();
notificationReceiver.setLocale("en-us");
notificationReceiver.setContactInformation("serena.davis@contoso.com");
notificationReceivers1.add(notificationReceiver);
notificationChannel1.setNotificationReceivers(notificationReceivers1);
notificationChannels.add(notificationChannel1);
alertRule.setNotificationChannels(notificationChannels);
com.microsoft.graph.models.devicemanagement.AlertRule result = graphClient.deviceManagement().monitoring().alertRules().post(alertRule);
Важно!
Пакеты SDK для Microsoft Graph по умолчанию используют версию API версии 1.0 и поддерживают не все типы, свойства и API, доступные в бета-версии. Дополнительные сведения о доступе к бета-API с помощью SDK см. в статье Использование пакетов Microsoft Graph SDK с бета-API.
Пакеты SDK для Microsoft Graph по умолчанию используют версию API версии 1.0 и поддерживают не все типы, свойства и API, доступные в бета-версии. Дополнительные сведения о доступе к бета-API с помощью SDK см. в статье Использование пакетов Microsoft Graph SDK с бета-API.
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\AlertRule;
use Microsoft\Graph\Generated\Models\RuleThreshold;
use Microsoft\Graph\Generated\Models\RuleCondition;
use Microsoft\Graph\Generated\Models\NotificationChannel;
use Microsoft\Graph\Generated\Models\NotificationReceiver;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new AlertRule();
$requestBody->setId('215c55cc-b1c9-4d36-a870-be5778101714');
$requestBody->setDisplayName('Azure network connection failure impacting Cloud PCs');
$requestBody->setSeverity(new RuleSeverityType('informational'));
$requestBody->setIsSystemRule(true);
$requestBody->setDescription('Azure network connection checks have failed and is potentially impacting existing Cloud PCs and blocking the provisioning of new Cloud PCs');
$requestBody->setEnabled(true);
$requestBody->setAlertRuleTemplate(new AlertRuleTemplate('cloudPcOnPremiseNetworkConnectionCheckScenario'));
$threshold = new RuleThreshold();
$threshold->setAggregation(new AggregationType('count'));
$threshold->setOperator(new OperatorType('greaterOrEqual'));
$threshold->setTarget(90);
$requestBody->setThreshold($threshold);
$conditionsRuleCondition1 = new RuleCondition();
$conditionsRuleCondition1->setRelationshipType(new RelationshipType('or'));
$conditionsRuleCondition1->setConditionCategory(new ConditionCategory('azureNetworkConnectionCheckFailures'));
$conditionsRuleCondition1->setAggregation(new AggregationType('count'));
$conditionsRuleCondition1->setOperator(new OperatorType('greaterOrEqual'));
$conditionsRuleCondition1->setThresholdValue('90');
$conditionsArray []= $conditionsRuleCondition1;
$requestBody->setConditions($conditionsArray);
$notificationChannelsNotificationChannel1 = new NotificationChannel();
$notificationChannelsNotificationChannel1->setNotificationChannelType(new NotificationChannelType('portal'));
$notificationChannelsNotificationChannel1->setNotificationReceivers([]);
$notificationChannelsArray []= $notificationChannelsNotificationChannel1;
$notificationChannelsNotificationChannel2 = new NotificationChannel();
$notificationChannelsNotificationChannel2->setNotificationChannelType(new NotificationChannelType('email'));
$notificationReceiversNotificationReceiver1 = new NotificationReceiver();
$notificationReceiversNotificationReceiver1->setLocale('en-us');
$notificationReceiversNotificationReceiver1->setContactInformation('serena.davis@contoso.com');
$notificationReceiversArray []= $notificationReceiversNotificationReceiver1;
$notificationChannelsNotificationChannel2->setNotificationReceivers($notificationReceiversArray);
$notificationChannelsArray []= $notificationChannelsNotificationChannel2;
$requestBody->setNotificationChannels($notificationChannelsArray);
$result = $graphServiceClient->deviceManagement()->monitoring()->alertRules()->post($requestBody)->wait();
Важно!
Пакеты SDK для Microsoft Graph по умолчанию используют версию API версии 1.0 и поддерживают не все типы, свойства и API, доступные в бета-версии. Дополнительные сведения о доступе к бета-API с помощью SDK см. в статье Использование пакетов Microsoft Graph SDK с бета-API.
Пакеты SDK для Microsoft Graph по умолчанию используют версию API версии 1.0 и поддерживают не все типы, свойства и API, доступные в бета-версии. Дополнительные сведения о доступе к бета-API с помощью SDK см. в статье Использование пакетов Microsoft Graph SDK с бета-API.
from msgraph import GraphServiceClient
from msgraph.generated.models.alert_rule import AlertRule
from msgraph.generated.models.rule_threshold import RuleThreshold
from msgraph.generated.models.rule_condition import RuleCondition
from msgraph.generated.models.notification_channel import NotificationChannel
from msgraph.generated.models.notification_receiver import NotificationReceiver
graph_client = GraphServiceClient(credentials, scopes)
request_body = AlertRule(
id = "215c55cc-b1c9-4d36-a870-be5778101714",
display_name = "Azure network connection failure impacting Cloud PCs",
severity = RuleSeverityType.Informational,
is_system_rule = 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,
alert_rule_template = AlertRuleTemplate.CloudPcOnPremiseNetworkConnectionCheckScenario,
threshold = RuleThreshold(
aggregation = AggregationType.Count,
operator = OperatorType.GreaterOrEqual,
target = 90,
),
conditions = [
RuleCondition(
relationship_type = RelationshipType.Or,
condition_category = ConditionCategory.AzureNetworkConnectionCheckFailures,
aggregation = AggregationType.Count,
operator = OperatorType.GreaterOrEqual,
threshold_value = "90",
),
],
notification_channels = [
NotificationChannel(
notification_channel_type = NotificationChannelType.Portal,
notification_receivers = [
],
),
NotificationChannel(
notification_channel_type = NotificationChannelType.Email,
notification_receivers = [
NotificationReceiver(
locale = "en-us",
contact_information = "serena.davis@contoso.com",
),
],
),
],
)
result = await graph_client.device_management.monitoring.alert_rules.post(request_body)
Важно!
Пакеты SDK для Microsoft Graph по умолчанию используют версию API версии 1.0 и поддерживают не все типы, свойства и API, доступные в бета-версии. Дополнительные сведения о доступе к бета-API с помощью SDK см. в статье Использование пакетов Microsoft Graph SDK с бета-API.
Ожидается в ближайшее время: в течение 2024 года мы постепенно откажемся от GitHub Issues как механизма обратной связи для контента и заменим его новой системой обратной связи. Дополнительные сведения см. в разделе https://aka.ms/ContentUserFeedback.