Erstellen Sie eine neue Aktivitätsprotokollwarnungsregel, oder aktualisieren Sie eine vorhandene Regel.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}?api-version=2020-10-01
URI-Parameter
Name |
In |
Erforderlich |
Typ |
Beschreibung |
activityLogAlertName
|
path |
True
|
string
|
Der Name der Aktivitätsprotokollwarnungsregel.
|
resourceGroupName
|
path |
True
|
string
|
Der Name der Ressourcengruppe. Für den Namen wird die Groß-/Kleinschreibung nicht beachtet.
|
subscriptionId
|
path |
True
|
string
|
Hierbei handelt es sich um die ID des Zielabonnements.
|
api-version
|
query |
True
|
string
|
Hierbei handelt es sich um die für diesen Vorgang zu verwendende API-Version.
|
Anforderungstext
Name |
Erforderlich |
Typ |
Beschreibung |
properties.actions
|
True
|
ActionList
|
Die Aktionen, die aktiviert werden, wenn die Bedingung erfüllt ist.
|
properties.condition
|
True
|
AlertRuleAllOfCondition
|
Die Bedingung, die dazu führt, dass diese Warnung aktiviert wird.
|
properties.scopes
|
True
|
string[]
|
Eine Liste der Ressourcen-IDs, die als Präfixe verwendet werden. Die Warnung gilt nur für Aktivitätsprotokollereignisse mit Ressourcen-IDs, die unter eines dieser Präfixe fallen. Diese Liste muss mindestens ein Element enthalten.
|
location
|
|
string
|
Der Speicherort der Ressource. Azure-Aktivitätsprotokollwarnungsregeln werden in den Regionen "Global", "Europa, Westen" und "Europa, Norden" unterstützt.
|
properties.description
|
|
string
|
Eine Beschreibung dieser Aktivitätsprotokollwarnungsregel.
|
properties.enabled
|
|
boolean
|
Gibt an, ob diese Aktivitätsprotokollwarnungsregel aktiviert ist. Wenn eine Aktivitätsprotokollwarnungsregel nicht aktiviert ist, wird keine ihrer Aktionen aktiviert.
|
tags
|
|
object
|
Die Tags der Ressource.
|
Antworten
Name |
Typ |
Beschreibung |
200 OK
|
ActivityLogAlertResource
|
Eine vorhandene Aktivitätsprotokollwarnungsregel wurde erfolgreich aktualisiert.
|
201 Created
|
ActivityLogAlertResource
|
Eine neue Aktivitätsprotokollwarnungsregel wurde erfolgreich erstellt.
|
Other Status Codes
|
ErrorResponse
|
Ein Fehler ist aufgetreten, und die Aktivitätsprotokollwarnungsregel konnte nicht erstellt oder aktualisiert werden.
|
Sicherheit
azure_auth
Azure Active Directory-OAuth2-Flow
Typ:
oauth2
Ablauf:
implicit
Autorisierungs-URL:
https://login.microsoftonline.com/common/oauth2/authorize
Bereiche
Name |
Beschreibung |
user_impersonation
|
Identitätswechsel Ihres Benutzerkontos
|
Beispiele
Create or update an Activity Log Alert rule
Beispielanforderung
PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRule?api-version=2020-10-01
{
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "Administrative"
},
{
"field": "level",
"equals": "Error"
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule."
}
}
import com.azure.resourcemanager.monitor.fluent.models.ActivityLogAlertResourceInner;
import com.azure.resourcemanager.monitor.models.ActionList;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertActionGroup;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertAllOfCondition;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertLeafCondition;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ActivityLogAlerts CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/
* ActivityLogAlertRule_CreateOrUpdate.json
*/
/**
* Sample code: Create or update an Activity Log Alert rule.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void createOrUpdateAnActivityLogAlertRule(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getActivityLogAlerts().createOrUpdateWithResponse(
"MyResourceGroup", "SampleActivityLogAlertRule",
new ActivityLogAlertResourceInner().withLocation("Global").withTags(mapOf())
.withScopes(Arrays.asList("/subscriptions/187f412d-1758-44d9-b052-169e2564721d"))
.withCondition(new ActivityLogAlertAllOfCondition().withAllOf(Arrays.asList(
new ActivityLogAlertLeafCondition().withField("category").withEquals("Administrative"),
new ActivityLogAlertLeafCondition().withField("level").withEquals("Error"))))
.withActions(new ActionList().withActionGroups(Arrays.asList(new ActivityLogAlertActionGroup()
.withActionGroupId(
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")
.withWebhookProperties(mapOf("sampleWebhookProperty", "SamplePropertyValue")))))
.withEnabled(true).withDescription("Description of sample Activity Log Alert rule."),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdate.json
func ExampleActivityLogAlertsClient_CreateOrUpdate_createOrUpdateAnActivityLogAlertRule() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewActivityLogAlertsClient().CreateOrUpdate(ctx, "MyResourceGroup", "SampleActivityLogAlertRule", armmonitor.ActivityLogAlertResource{
Location: to.Ptr("Global"),
Tags: map[string]*string{},
Properties: &armmonitor.AlertRuleProperties{
Description: to.Ptr("Description of sample Activity Log Alert rule."),
Actions: &armmonitor.ActionList{
ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
{
ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
WebhookProperties: map[string]*string{
"sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
},
}},
},
Condition: &armmonitor.AlertRuleAllOfCondition{
AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
{
Equals: to.Ptr("Administrative"),
Field: to.Ptr("category"),
},
{
Equals: to.Ptr("Error"),
Field: to.Ptr("level"),
}},
},
Enabled: to.Ptr(true),
Scopes: []*string{
to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ActivityLogAlertResource = armmonitor.ActivityLogAlertResource{
// Name: to.Ptr("SampleActivityLogAlertRule"),
// Type: to.Ptr("Microsoft.Insights/ActivityLogAlerts"),
// ID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRule"),
// Location: to.Ptr("Global"),
// Tags: map[string]*string{
// },
// Properties: &armmonitor.AlertRuleProperties{
// Description: to.Ptr("Description of sample Activity Log Alert rule."),
// Actions: &armmonitor.ActionList{
// ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
// {
// ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/actionGroups/SampleActionGroup"),
// WebhookProperties: map[string]*string{
// "sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
// },
// }},
// },
// Condition: &armmonitor.AlertRuleAllOfCondition{
// AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
// {
// Equals: to.Ptr("Administrative"),
// Field: to.Ptr("Category"),
// },
// {
// Equals: to.Ptr("Error"),
// Field: to.Ptr("Level"),
// }},
// },
// Enabled: to.Ptr(true),
// Scopes: []*string{
// to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a new Activity Log Alert rule or update an existing one.
*
* @summary Create a new Activity Log Alert rule or update an existing one.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdate.json
*/
async function createOrUpdateAnActivityLogAlertRule() {
const subscriptionId =
process.env["MONITOR_SUBSCRIPTION_ID"] || "187f412d-1758-44d9-b052-169e2564721d";
const resourceGroupName = process.env["MONITOR_RESOURCE_GROUP"] || "MyResourceGroup";
const activityLogAlertName = "SampleActivityLogAlertRule";
const activityLogAlertRule = {
description: "Description of sample Activity Log Alert rule.",
actions: {
actionGroups: [
{
actionGroupId:
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
webhookProperties: { sampleWebhookProperty: "SamplePropertyValue" },
},
],
},
condition: {
allOf: [
{ equals: "Administrative", field: "category" },
{ equals: "Error", field: "level" },
],
},
enabled: true,
location: "Global",
scopes: ["/subscriptions/187f412d-1758-44d9-b052-169e2564721d"],
tags: {},
};
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential, subscriptionId);
const result = await client.activityLogAlerts.createOrUpdate(
resourceGroupName,
activityLogAlertName,
activityLogAlertRule,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Monitor.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdate.json
// this example is just showing the usage of "ActivityLogAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d";
string resourceGroupName = "MyResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ActivityLogAlertResource
ActivityLogAlertCollection collection = resourceGroupResource.GetActivityLogAlerts();
// invoke the operation
string activityLogAlertName = "SampleActivityLogAlertRule";
ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global"))
{
Scopes =
{
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d"
},
ConditionAllOf =
{
new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "category",
EqualsValue = "Administrative",
},new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "level",
EqualsValue = "Error",
}
},
ActionsActionGroups =
{
new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"))
{
WebhookProperties =
{
["sampleWebhookProperty"] = "SamplePropertyValue",
},
}
},
IsEnabled = true,
Description = "Description of sample Activity Log Alert rule.",
Tags =
{
},
};
ArmOperation<ActivityLogAlertResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data);
ActivityLogAlertResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ActivityLogAlertData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRule",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRule",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "Category",
"equals": "Administrative"
},
{
"field": "Level",
"equals": "Error"
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule."
}
}
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRule",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRule",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "Category",
"equals": "Administrative"
},
{
"field": "Level",
"equals": "Error"
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule."
}
}
Create or update an Activity Log Alert rule with 'anyOf' condition
Beispielanforderung
PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition?api-version=2020-10-01
{
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"anyOf": [
{
"field": "properties.incidentType",
"equals": "Incident"
},
{
"field": "properties.incidentType",
"equals": "Maintenance"
}
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
}
}
import com.azure.resourcemanager.monitor.fluent.models.ActivityLogAlertResourceInner;
import com.azure.resourcemanager.monitor.models.ActionList;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertActionGroup;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertAllOfCondition;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertLeafCondition;
import com.azure.resourcemanager.monitor.models.AlertRuleLeafCondition;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ActivityLogAlerts CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/
* ActivityLogAlertRule_CreateOrUpdateRuleWithAnyOfCondition.json
*/
/**
* Sample code: Create or update an Activity Log Alert rule with 'anyOf' condition.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateAnActivityLogAlertRuleWithAnyOfCondition(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getActivityLogAlerts().createOrUpdateWithResponse(
"MyResourceGroup", "SampleActivityLogAlertRuleWithAnyOfCondition",
new ActivityLogAlertResourceInner().withLocation("Global").withTags(mapOf())
.withScopes(Arrays.asList("subscriptions/187f412d-1758-44d9-b052-169e2564721d"))
.withCondition(new ActivityLogAlertAllOfCondition().withAllOf(Arrays.asList(
new ActivityLogAlertLeafCondition().withField("category").withEquals("ServiceHealth"),
new ActivityLogAlertLeafCondition().withAnyOf(Arrays.asList(
new AlertRuleLeafCondition().withField("properties.incidentType").withEquals("Incident"),
new AlertRuleLeafCondition().withField("properties.incidentType").withEquals("Maintenance"))))))
.withActions(new ActionList().withActionGroups(Arrays.asList(new ActivityLogAlertActionGroup()
.withActionGroupId(
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")
.withWebhookProperties(mapOf("sampleWebhookProperty", "SamplePropertyValue")))))
.withEnabled(true)
.withDescription("Description of sample Activity Log Alert rule with 'anyOf' condition."),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithAnyOfCondition.json
func ExampleActivityLogAlertsClient_CreateOrUpdate_createOrUpdateAnActivityLogAlertRuleWithAnyOfCondition() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewActivityLogAlertsClient().CreateOrUpdate(ctx, "MyResourceGroup", "SampleActivityLogAlertRuleWithAnyOfCondition", armmonitor.ActivityLogAlertResource{
Location: to.Ptr("Global"),
Tags: map[string]*string{},
Properties: &armmonitor.AlertRuleProperties{
Description: to.Ptr("Description of sample Activity Log Alert rule with 'anyOf' condition."),
Actions: &armmonitor.ActionList{
ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
{
ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
WebhookProperties: map[string]*string{
"sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
},
}},
},
Condition: &armmonitor.AlertRuleAllOfCondition{
AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
{
Equals: to.Ptr("ServiceHealth"),
Field: to.Ptr("category"),
},
{
AnyOf: []*armmonitor.AlertRuleLeafCondition{
{
Equals: to.Ptr("Incident"),
Field: to.Ptr("properties.incidentType"),
},
{
Equals: to.Ptr("Maintenance"),
Field: to.Ptr("properties.incidentType"),
}},
}},
},
Enabled: to.Ptr(true),
Scopes: []*string{
to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ActivityLogAlertResource = armmonitor.ActivityLogAlertResource{
// Name: to.Ptr("SampleActivityLogAlertRuleWithAnyOfCondition"),
// Type: to.Ptr("Microsoft.Insights/ActivityLogAlerts"),
// ID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition"),
// Location: to.Ptr("Global"),
// Tags: map[string]*string{
// },
// Properties: &armmonitor.AlertRuleProperties{
// Description: to.Ptr("Description of sample Activity Log Alert rule with 'anyOf' condition."),
// Actions: &armmonitor.ActionList{
// ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
// {
// ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
// WebhookProperties: map[string]*string{
// "sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
// },
// }},
// },
// Condition: &armmonitor.AlertRuleAllOfCondition{
// AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
// {
// Equals: to.Ptr("ServiceHealth"),
// Field: to.Ptr("category"),
// },
// {
// AnyOf: []*armmonitor.AlertRuleLeafCondition{
// {
// Equals: to.Ptr("Incident"),
// Field: to.Ptr("properties.incidentType"),
// },
// {
// Equals: to.Ptr("Maintenance"),
// Field: to.Ptr("properties.incidentType"),
// }},
// }},
// },
// Enabled: to.Ptr(true),
// Scopes: []*string{
// to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a new Activity Log Alert rule or update an existing one.
*
* @summary Create a new Activity Log Alert rule or update an existing one.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithAnyOfCondition.json
*/
async function createOrUpdateAnActivityLogAlertRuleWithAnyOfCondition() {
const subscriptionId =
process.env["MONITOR_SUBSCRIPTION_ID"] || "187f412d-1758-44d9-b052-169e2564721d";
const resourceGroupName = process.env["MONITOR_RESOURCE_GROUP"] || "MyResourceGroup";
const activityLogAlertName = "SampleActivityLogAlertRuleWithAnyOfCondition";
const activityLogAlertRule = {
description: "Description of sample Activity Log Alert rule with 'anyOf' condition.",
actions: {
actionGroups: [
{
actionGroupId:
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
webhookProperties: { sampleWebhookProperty: "SamplePropertyValue" },
},
],
},
condition: {
allOf: [
{ equals: "ServiceHealth", field: "category" },
{
anyOf: [
{ equals: "Incident", field: "properties.incidentType" },
{ equals: "Maintenance", field: "properties.incidentType" },
],
},
],
},
enabled: true,
location: "Global",
scopes: ["subscriptions/187f412d-1758-44d9-b052-169e2564721d"],
tags: {},
};
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential, subscriptionId);
const result = await client.activityLogAlerts.createOrUpdate(
resourceGroupName,
activityLogAlertName,
activityLogAlertRule,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Monitor.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithAnyOfCondition.json
// this example is just showing the usage of "ActivityLogAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d";
string resourceGroupName = "MyResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ActivityLogAlertResource
ActivityLogAlertCollection collection = resourceGroupResource.GetActivityLogAlerts();
// invoke the operation
string activityLogAlertName = "SampleActivityLogAlertRuleWithAnyOfCondition";
ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global"))
{
Scopes =
{
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
},
ConditionAllOf =
{
new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "category",
EqualsValue = "ServiceHealth",
},new ActivityLogAlertAnyOfOrLeafCondition()
{
AnyOf =
{
new AlertRuleLeafCondition()
{
Field = "properties.incidentType",
EqualsValue = "Incident",
},new AlertRuleLeafCondition()
{
Field = "properties.incidentType",
EqualsValue = "Maintenance",
}
},
}
},
ActionsActionGroups =
{
new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"))
{
WebhookProperties =
{
["sampleWebhookProperty"] = "SamplePropertyValue",
},
}
},
IsEnabled = true,
Description = "Description of sample Activity Log Alert rule with 'anyOf' condition.",
Tags =
{
},
};
ArmOperation<ActivityLogAlertResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data);
ActivityLogAlertResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ActivityLogAlertData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRuleWithAnyOfCondition",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"anyOf": [
{
"field": "properties.incidentType",
"equals": "Incident"
},
{
"field": "properties.incidentType",
"equals": "Maintenance"
}
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
}
}
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithAnyOfCondition",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRuleWithAnyOfCondition",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"anyOf": [
{
"field": "properties.incidentType",
"equals": "Incident"
},
{
"field": "properties.incidentType",
"equals": "Maintenance"
}
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'anyOf' condition."
}
}
Create or update an Activity Log Alert rule with 'containsAny'
Beispielanforderung
PUT https://management.azure.com/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny?api-version=2020-10-01
{
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
"containsAny": [
"North Europe",
"West Europe"
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'containsAny'."
}
}
import com.azure.resourcemanager.monitor.fluent.models.ActivityLogAlertResourceInner;
import com.azure.resourcemanager.monitor.models.ActionList;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertActionGroup;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertAllOfCondition;
import com.azure.resourcemanager.monitor.models.ActivityLogAlertLeafCondition;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* Samples for ActivityLogAlerts CreateOrUpdate.
*/
public final class Main {
/*
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/
* ActivityLogAlertRule_CreateOrUpdateRuleWithContainsAny.json
*/
/**
* Sample code: Create or update an Activity Log Alert rule with 'containsAny'.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void
createOrUpdateAnActivityLogAlertRuleWithContainsAny(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getActivityLogAlerts()
.createOrUpdateWithResponse("MyResourceGroup", "SampleActivityLogAlertRuleWithContainsAny",
new ActivityLogAlertResourceInner().withLocation("Global").withTags(mapOf())
.withScopes(Arrays.asList("subscriptions/187f412d-1758-44d9-b052-169e2564721d"))
.withCondition(new ActivityLogAlertAllOfCondition().withAllOf(Arrays.asList(
new ActivityLogAlertLeafCondition().withField("category").withEquals("ServiceHealth"),
new ActivityLogAlertLeafCondition()
.withField("properties.impactedServices[*].ImpactedRegions[*].RegionName")
.withContainsAny(Arrays.asList("North Europe", "West Europe")))))
.withActions(new ActionList().withActionGroups(Arrays.asList(new ActivityLogAlertActionGroup()
.withActionGroupId(
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")
.withWebhookProperties(mapOf("sampleWebhookProperty", "SamplePropertyValue")))))
.withEnabled(true)
.withDescription("Description of sample Activity Log Alert rule with 'containsAny'."),
com.azure.core.util.Context.NONE);
}
// Use "Map.of" if available
@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armmonitor_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/monitor/armmonitor"
)
// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/969fd0c2634fbcc1975d7abe3749330a5145a97c/specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithContainsAny.json
func ExampleActivityLogAlertsClient_CreateOrUpdate_createOrUpdateAnActivityLogAlertRuleWithContainsAny() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armmonitor.NewClientFactory("<subscription-id>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewActivityLogAlertsClient().CreateOrUpdate(ctx, "MyResourceGroup", "SampleActivityLogAlertRuleWithContainsAny", armmonitor.ActivityLogAlertResource{
Location: to.Ptr("Global"),
Tags: map[string]*string{},
Properties: &armmonitor.AlertRuleProperties{
Description: to.Ptr("Description of sample Activity Log Alert rule with 'containsAny'."),
Actions: &armmonitor.ActionList{
ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
{
ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
WebhookProperties: map[string]*string{
"sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
},
}},
},
Condition: &armmonitor.AlertRuleAllOfCondition{
AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
{
Equals: to.Ptr("ServiceHealth"),
Field: to.Ptr("category"),
},
{
ContainsAny: []*string{
to.Ptr("North Europe"),
to.Ptr("West Europe")},
Field: to.Ptr("properties.impactedServices[*].ImpactedRegions[*].RegionName"),
}},
},
Enabled: to.Ptr(true),
Scopes: []*string{
to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
},
}, nil)
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res.ActivityLogAlertResource = armmonitor.ActivityLogAlertResource{
// Name: to.Ptr("SampleActivityLogAlertRuleWithContainsAny"),
// Type: to.Ptr("Microsoft.Insights/ActivityLogAlerts"),
// ID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny"),
// Location: to.Ptr("Global"),
// Tags: map[string]*string{
// },
// Properties: &armmonitor.AlertRuleProperties{
// Description: to.Ptr("Description of sample Activity Log Alert rule with 'containsAny'."),
// Actions: &armmonitor.ActionList{
// ActionGroups: []*armmonitor.ActionGroupAutoGenerated{
// {
// ActionGroupID: to.Ptr("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"),
// WebhookProperties: map[string]*string{
// "sampleWebhookProperty": to.Ptr("SamplePropertyValue"),
// },
// }},
// },
// Condition: &armmonitor.AlertRuleAllOfCondition{
// AllOf: []*armmonitor.AlertRuleAnyOfOrLeafCondition{
// {
// Equals: to.Ptr("ServiceHealth"),
// Field: to.Ptr("category"),
// },
// {
// ContainsAny: []*string{
// to.Ptr("North Europe"),
// to.Ptr("West Europe")},
// Field: to.Ptr("properties.impactedServices[*].ImpactedRegions[*].RegionName"),
// }},
// },
// Enabled: to.Ptr(true),
// Scopes: []*string{
// to.Ptr("subscriptions/187f412d-1758-44d9-b052-169e2564721d")},
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { MonitorClient } = require("@azure/arm-monitor");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to Create a new Activity Log Alert rule or update an existing one.
*
* @summary Create a new Activity Log Alert rule or update an existing one.
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithContainsAny.json
*/
async function createOrUpdateAnActivityLogAlertRuleWithContainsAny() {
const subscriptionId =
process.env["MONITOR_SUBSCRIPTION_ID"] || "187f412d-1758-44d9-b052-169e2564721d";
const resourceGroupName = process.env["MONITOR_RESOURCE_GROUP"] || "MyResourceGroup";
const activityLogAlertName = "SampleActivityLogAlertRuleWithContainsAny";
const activityLogAlertRule = {
description: "Description of sample Activity Log Alert rule with 'containsAny'.",
actions: {
actionGroups: [
{
actionGroupId:
"/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
webhookProperties: { sampleWebhookProperty: "SamplePropertyValue" },
},
],
},
condition: {
allOf: [
{ equals: "ServiceHealth", field: "category" },
{
containsAny: ["North Europe", "West Europe"],
field: "properties.impactedServices[*].ImpactedRegions[*].RegionName",
},
],
},
enabled: true,
location: "Global",
scopes: ["subscriptions/187f412d-1758-44d9-b052-169e2564721d"],
tags: {},
};
const credential = new DefaultAzureCredential();
const client = new MonitorClient(credential, subscriptionId);
const result = await client.activityLogAlerts.createOrUpdate(
resourceGroupName,
activityLogAlertName,
activityLogAlertRule,
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Monitor.Models;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Monitor;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_CreateOrUpdateRuleWithContainsAny.json
// this example is just showing the usage of "ActivityLogAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this ResourceGroupResource created on azure
// for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource
string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d";
string resourceGroupName = "MyResourceGroup";
ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName);
ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId);
// get the collection of this ActivityLogAlertResource
ActivityLogAlertCollection collection = resourceGroupResource.GetActivityLogAlerts();
// invoke the operation
string activityLogAlertName = "SampleActivityLogAlertRuleWithContainsAny";
ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global"))
{
Scopes =
{
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
},
ConditionAllOf =
{
new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "category",
EqualsValue = "ServiceHealth",
},new ActivityLogAlertAnyOfOrLeafCondition()
{
Field = "properties.impactedServices[*].ImpactedRegions[*].RegionName",
ContainsAny =
{
"North Europe","West Europe"
},
}
},
ActionsActionGroups =
{
new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup"))
{
WebhookProperties =
{
["sampleWebhookProperty"] = "SamplePropertyValue",
},
}
},
IsEnabled = true,
Description = "Description of sample Activity Log Alert rule with 'containsAny'.",
Tags =
{
},
};
ArmOperation<ActivityLogAlertResource> lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data);
ActivityLogAlertResource result = lro.Value;
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
ActivityLogAlertData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Beispiel für eine Antwort
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRuleWithContainsAny",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
"containsAny": [
"North Europe",
"West Europe"
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'containsAny'."
}
}
{
"id": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/microsoft.insights/activityLogAlerts/SampleActivityLogAlertRuleWithContainsAny",
"type": "Microsoft.Insights/ActivityLogAlerts",
"name": "SampleActivityLogAlertRuleWithContainsAny",
"location": "Global",
"tags": {},
"properties": {
"scopes": [
"subscriptions/187f412d-1758-44d9-b052-169e2564721d"
],
"condition": {
"allOf": [
{
"field": "category",
"equals": "ServiceHealth"
},
{
"field": "properties.impactedServices[*].ImpactedRegions[*].RegionName",
"containsAny": [
"North Europe",
"West Europe"
]
}
]
},
"actions": {
"actionGroups": [
{
"actionGroupId": "/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup",
"webhookProperties": {
"sampleWebhookProperty": "SamplePropertyValue"
}
}
]
},
"enabled": true,
"description": "Description of sample Activity Log Alert rule with 'containsAny'."
}
}
Definitionen
Name |
Beschreibung |
ActionGroup
|
Ein Zeiger auf eine Azure-Aktionsgruppe.
|
ActionList
|
Eine Liste der Aktionen für Aktivitätsprotokollwarnungen.
|
ActivityLogAlertResource
|
Eine Aktivitätsprotokoll-Warnungsregelressource.
|
AlertRuleAllOfCondition
|
Eine Regelbedingung für Aktivitätsprotokollwarnungen, die erfüllt ist, wenn alle Memberbedingungen erfüllt sind.
|
AlertRuleAnyOfOrLeafCondition
|
Eine Regelbedingung für Aktivitätsprotokollwarnungen, die erfüllt ist, wenn alle Memberbedingungen erfüllt sind.
Jede Bedingung kann einen der folgenden Typen aufweisen: Wichtig: Jeder Typ verfügt über eine eindeutige Teilmenge von Eigenschaften. Eigenschaften aus verschiedenen Typen KÖNNEN NICHT in einer Bedingung vorhanden sein.
-
Blattbedingung: muss "field" und entweder "equals" oder "containsAny" enthalten.
Beachten Sie, dass "anyOf" nicht in einer Blattbedingung festgelegt werden darf.
-
AnyOf-Bedingung: darf nur "anyOf" (ein Array von Blattbedingungen) enthalten.
Beachten Sie, dass "field", "equals" und "containsAny" nicht in einer AnyOf-Bedingung festgelegt werden dürfen.
|
AlertRuleLeafCondition
|
Eine Regelbedingung für aktivitätsprotokollwarnungen, die durch den Vergleich des Felds und des Werts eines Aktivitätsprotokollereignisses erfüllt wird.
Diese Bedingung muss "field" und entweder "equals" oder "containsAny" enthalten.
|
ErrorResponse
|
Die Fehlerantwort.
|
ActionGroup
Ein Zeiger auf eine Azure-Aktionsgruppe.
Name |
Typ |
Beschreibung |
actionGroupId
|
string
|
Die Ressourcen-ID der Aktionsgruppe. Dies darf nicht NULL oder leer sein.
|
webhookProperties
|
object
|
das Wörterbuch der benutzerdefinierten Eigenschaften, die in den post-Vorgang eingeschlossen werden sollen. Diese Daten werden an die Webhooknutzlast angefügt.
|
ActionList
Eine Liste der Aktionen für Aktivitätsprotokollwarnungen.
Name |
Typ |
Beschreibung |
actionGroups
|
ActionGroup[]
|
Die Liste der Aktionsgruppen.
|
ActivityLogAlertResource
Eine Aktivitätsprotokoll-Warnungsregelressource.
Name |
Typ |
Standardwert |
Beschreibung |
id
|
string
|
|
Die Ressourcen-ID.
|
location
|
string
|
global
|
Der Speicherort der Ressource. Azure-Aktivitätsprotokollwarnungsregeln werden in den Regionen "Global", "Europa, Westen" und "Europa, Norden" unterstützt.
|
name
|
string
|
|
Der Name der Ressource.
|
properties.actions
|
ActionList
|
|
Die Aktionen, die aktiviert werden, wenn die Bedingung erfüllt ist.
|
properties.condition
|
AlertRuleAllOfCondition
|
|
Die Bedingung, die dazu führt, dass diese Warnung aktiviert wird.
|
properties.description
|
string
|
|
Eine Beschreibung dieser Aktivitätsprotokollwarnungsregel.
|
properties.enabled
|
boolean
|
True
|
Gibt an, ob diese Aktivitätsprotokollwarnungsregel aktiviert ist. Wenn eine Aktivitätsprotokollwarnungsregel nicht aktiviert ist, wird keine ihrer Aktionen aktiviert.
|
properties.scopes
|
string[]
|
|
Eine Liste der Ressourcen-IDs, die als Präfixe verwendet werden. Die Warnung gilt nur für Aktivitätsprotokollereignisse mit Ressourcen-IDs, die unter eines dieser Präfixe fallen. Diese Liste muss mindestens ein Element enthalten.
|
tags
|
object
|
|
Die Tags der Ressource.
|
type
|
string
|
|
Der Typ der Ressource.
|
AlertRuleAllOfCondition
Eine Regelbedingung für Aktivitätsprotokollwarnungen, die erfüllt ist, wenn alle Memberbedingungen erfüllt sind.
AlertRuleAnyOfOrLeafCondition
Eine Regelbedingung für Aktivitätsprotokollwarnungen, die erfüllt ist, wenn alle Memberbedingungen erfüllt sind.
Jede Bedingung kann einen der folgenden Typen aufweisen: Wichtig: Jeder Typ verfügt über eine eindeutige Teilmenge von Eigenschaften. Eigenschaften aus verschiedenen Typen KÖNNEN NICHT in einer Bedingung vorhanden sein.
-
Blattbedingung: muss "field" und entweder "equals" oder "containsAny" enthalten.
Beachten Sie, dass "anyOf" nicht in einer Blattbedingung festgelegt werden darf.
-
AnyOf-Bedingung: darf nur "anyOf" (ein Array von Blattbedingungen) enthalten.
Beachten Sie, dass "field", "equals" und "containsAny" nicht in einer AnyOf-Bedingung festgelegt werden dürfen.
Name |
Typ |
Beschreibung |
anyOf
|
AlertRuleLeafCondition[]
|
Eine Aktivitätsprotokollwarnungsregel "anyOf"-Bedingung.
Eine Regelbedingung für Aktivitätsprotokollwarnungen, die erfüllt ist, wenn mindestens eine ihrer Memberblattbedingungen erfüllt ist.
|
containsAny
|
string[]
|
Der Wert des Ereignisfelds wird mit den Werten in diesem Array verglichen (ohne Berücksichtigung der Groß-/Kleinschreibung), um zu bestimmen, ob die Bedingung erfüllt ist.
|
equals
|
string
|
Der Wert des Ereignisfelds wird mit diesem Wert verglichen (ohne Berücksichtigung der Groß-/Kleinschreibung), um zu bestimmen, ob die Bedingung erfüllt ist.
|
field
|
string
|
Der Name des Felds des Aktivitätsprotokollereignisses, das von dieser Bedingung untersucht wird.
Die möglichen Werte für dieses Feld sind (ohne Beachtung der Groß-/Kleinschreibung): "resourceId", "category", "caller", "level", "operationName", "resourceGroup", "resourceProvider", "status", "subStatus", "resourceType" oder alles, was mit "properties" beginnt.
|
AlertRuleLeafCondition
Eine Regelbedingung für aktivitätsprotokollwarnungen, die durch den Vergleich des Felds und des Werts eines Aktivitätsprotokollereignisses erfüllt wird.
Diese Bedingung muss "field" und entweder "equals" oder "containsAny" enthalten.
Name |
Typ |
Beschreibung |
containsAny
|
string[]
|
Der Wert des Ereignisfelds wird mit den Werten in diesem Array verglichen (ohne Berücksichtigung der Groß-/Kleinschreibung), um zu bestimmen, ob die Bedingung erfüllt ist.
|
equals
|
string
|
Der Wert des Ereignisfelds wird mit diesem Wert verglichen (ohne Berücksichtigung der Groß-/Kleinschreibung), um zu bestimmen, ob die Bedingung erfüllt ist.
|
field
|
string
|
Der Name des Felds des Aktivitätsprotokollereignisses, das von dieser Bedingung untersucht wird.
Die möglichen Werte für dieses Feld sind (ohne Beachtung der Groß-/Kleinschreibung): "resourceId", "category", "caller", "level", "operationName", "resourceGroup", "resourceProvider", "status", "subStatus", "resourceType" oder alles, was mit "properties" beginnt.
|
ErrorResponse
Die Fehlerantwort.
Name |
Typ |
Beschreibung |
code
|
string
|
Der Fehlercode.
|
message
|
string
|
Die Fehlermeldung, die angibt, warum der Vorgang fehlgeschlagen ist.
|