Crie uma nova regra de Alerta do Registo de Atividades ou atualize uma existente.
PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Insights/activityLogAlerts/{activityLogAlertName}?api-version=2020-10-01
Parâmetros do URI
Name |
Em |
Necessário |
Tipo |
Description |
activityLogAlertName
|
path |
True
|
string
|
O nome da regra de Alerta do Registo de Atividades.
|
resourceGroupName
|
path |
True
|
string
|
O nome do grupo de recursos. O nome não é sensível a maiúsculas e minúsculas.
|
subscriptionId
|
path |
True
|
string
|
O ID da subscrição de destino.
|
api-version
|
query |
True
|
string
|
A versão da API a utilizar para esta operação.
|
Corpo do Pedido
Name |
Necessário |
Tipo |
Description |
properties.actions
|
True
|
ActionList
|
As ações que serão ativadas quando a condição for cumprida.
|
properties.condition
|
True
|
AlertRuleAllOfCondition
|
A condição que fará com que este alerta seja ativado.
|
properties.scopes
|
True
|
string[]
|
Uma lista de IDs de recursos que serão utilizados como prefixos. O alerta só se aplicará a eventos do Registo de Atividades com IDs de recursos que se enquadram num destes prefixos. Esta lista tem de incluir, pelo menos, um item.
|
location
|
|
string
|
A localização do recurso. As regras de Alerta do Registo de Atividades do Azure são suportadas nas regiões Global, Europa Ocidental e Europa do Norte.
|
properties.description
|
|
string
|
Uma descrição desta regra de Alerta do Registo de Atividades.
|
properties.enabled
|
|
boolean
|
Indica se esta regra de Alerta do Registo de Atividades está ativada. Se uma regra de Alerta do Registo de Atividades não estiver ativada, nenhuma das ações será ativada.
|
tags
|
|
object
|
As etiquetas do recurso.
|
Respostas
Name |
Tipo |
Description |
200 OK
|
ActivityLogAlertResource
|
Uma regra de Alerta do Registo de Atividades existente foi atualizada com êxito.
|
201 Created
|
ActivityLogAlertResource
|
Foi criada com êxito uma nova regra de Alerta do Registo de Atividades.
|
Other Status Codes
|
ErrorResponse
|
Ocorreu um erro e não foi possível criar ou atualizar a regra de Alerta do Registo de Atividades.
|
Segurança
azure_auth
Fluxo OAuth2 do Azure Active Directory
Tipo:
oauth2
Fluxo:
implicit
URL de Autorização:
https://login.microsoftonline.com/common/oauth2/authorize
Âmbitos
Name |
Description |
user_impersonation
|
representar a sua conta de utilizador
|
Exemplos
Create or update an Activity Log Alert rule
Pedido de amostra
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
Resposta da amostra
{
"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
Pedido de amostra
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
Resposta da amostra
{
"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'
Pedido de amostra
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
Resposta da amostra
{
"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'."
}
}
Definições
Name |
Description |
ActionGroup
|
Um ponteiro para um Grupo de Ações do Azure.
|
ActionList
|
Uma lista de ações de regras de Alerta do Registo de Atividades.
|
ActivityLogAlertResource
|
Um recurso de regra de Alerta do Registo de Atividades.
|
AlertRuleAllOfCondition
|
Uma condição de regra de Alerta do Registo de Atividades que é cumprida quando todas as condições dos membros são cumpridas.
|
AlertRuleAnyOfOrLeafCondition
|
Uma condição de regra de Alerta do Registo de Atividades que é cumprida quando todas as condições dos membros são cumpridas.
Cada condição pode ser de um dos seguintes tipos: Importante: cada tipo tem o seu subconjunto exclusivo de propriedades. Não é possível existir propriedades de diferentes tipos numa condição.
-
Condição de Folha - tem de conter "campo" e "igual" ou "containsAny".
Tenha em atenção que "anyOf" não deve ser definido numa Condição de Folha.
-
AnyOf Condition - tem de conter apenas "anyOf" (que é uma matriz de Condições de Folha).
Tenha em atenção que "campo", "igual a" e "containsAny" não devem ser definidos numa Condição AnyOf.
|
AlertRuleLeafCondition
|
Uma condição de regra de Alerta do Registo de Atividades que é cumprida ao comparar o campo e o valor de um evento do Registo de Atividades.
Esta condição tem de conter "campo" e "igual" ou "containsAny".
|
ErrorResponse
|
A resposta do erro.
|
ActionGroup
Um ponteiro para um Grupo de Ações do Azure.
Name |
Tipo |
Description |
actionGroupId
|
string
|
O ID do recurso do Grupo de Ações. Não pode ser nulo ou estar vazio.
|
webhookProperties
|
object
|
o dicionário de propriedades personalizadas a incluir com a operação de publicação. Estes dados são anexados ao payload do webhook.
|
ActionList
Uma lista de ações de regras de Alerta do Registo de Atividades.
Name |
Tipo |
Description |
actionGroups
|
ActionGroup[]
|
A lista dos Grupos de Ações.
|
ActivityLogAlertResource
Um recurso de regra de Alerta do Registo de Atividades.
Name |
Tipo |
Default value |
Description |
id
|
string
|
|
O ID do recurso.
|
location
|
string
|
global
|
A localização do recurso. As regras de Alerta do Registo de Atividades do Azure são suportadas nas regiões Global, Europa Ocidental e Europa do Norte.
|
name
|
string
|
|
O nome do recurso.
|
properties.actions
|
ActionList
|
|
As ações que serão ativadas quando a condição for cumprida.
|
properties.condition
|
AlertRuleAllOfCondition
|
|
A condição que fará com que este alerta seja ativado.
|
properties.description
|
string
|
|
Uma descrição desta regra de Alerta do Registo de Atividades.
|
properties.enabled
|
boolean
|
True
|
Indica se esta regra de Alerta do Registo de Atividades está ativada. Se uma regra de Alerta do Registo de Atividades não estiver ativada, nenhuma das ações será ativada.
|
properties.scopes
|
string[]
|
|
Uma lista de IDs de recursos que serão utilizados como prefixos. O alerta só se aplicará a eventos do Registo de Atividades com IDs de recursos que se enquadram num destes prefixos. Esta lista tem de incluir, pelo menos, um item.
|
tags
|
object
|
|
As etiquetas do recurso.
|
type
|
string
|
|
O tipo do recurso.
|
AlertRuleAllOfCondition
Uma condição de regra de Alerta do Registo de Atividades que é cumprida quando todas as condições dos membros são cumpridas.
AlertRuleAnyOfOrLeafCondition
Uma condição de regra de Alerta do Registo de Atividades que é cumprida quando todas as condições dos membros são cumpridas.
Cada condição pode ser de um dos seguintes tipos: Importante: cada tipo tem o seu subconjunto exclusivo de propriedades. Não é possível existir propriedades de diferentes tipos numa condição.
-
Condição de Folha - tem de conter "campo" e "igual" ou "containsAny".
Tenha em atenção que "anyOf" não deve ser definido numa Condição de Folha.
-
AnyOf Condition - tem de conter apenas "anyOf" (que é uma matriz de Condições de Folha).
Tenha em atenção que "campo", "igual a" e "containsAny" não devem ser definidos numa Condição AnyOf.
Name |
Tipo |
Description |
anyOf
|
AlertRuleLeafCondition[]
|
Uma condição "anyOf" da regra de Alerta do Registo de Atividades.
Uma condição de regra de Alerta do Registo de Atividades que é cumprida quando pelo menos uma das condições de folha membro é cumprida.
|
containsAny
|
string[]
|
O valor do campo do evento será comparado com os valores nesta matriz (não sensível a maiúsculas e minúsculas) para determinar se a condição é cumprida.
|
equals
|
string
|
O valor do campo do evento será comparado a este valor (não sensível a maiúsculas e minúsculas) para determinar se a condição é cumprida.
|
field
|
string
|
O nome do campo do evento do Registo de Atividades que esta condição irá examinar.
Os valores possíveis para este campo são (não sensíveis a maiúsculas e minúsculas): "resourceId", "category", "caller", "level", "operationName", "resourceGroup", "resourceProvider", "status", "subStatus", "resourceType" ou qualquer coisa que comece com "propriedades".
|
AlertRuleLeafCondition
Uma condição de regra de Alerta do Registo de Atividades que é cumprida ao comparar o campo e o valor de um evento do Registo de Atividades.
Esta condição tem de conter "campo" e "igual" ou "containsAny".
Name |
Tipo |
Description |
containsAny
|
string[]
|
O valor do campo do evento será comparado com os valores nesta matriz (não sensível a maiúsculas e minúsculas) para determinar se a condição é cumprida.
|
equals
|
string
|
O valor do campo do evento será comparado a este valor (não sensível a maiúsculas e minúsculas) para determinar se a condição é cumprida.
|
field
|
string
|
O nome do campo do evento do Registo de Atividades que esta condição irá examinar.
Os valores possíveis para este campo são (não sensíveis a maiúsculas e minúsculas): "resourceId", "category", "caller", "level", "operationName", "resourceGroup", "resourceProvider", "status", "subStatus", "resourceType" ou qualquer coisa que comece com "propriedades".
|
ErrorResponse
A resposta do erro.
Name |
Tipo |
Description |
code
|
string
|
O código de erro.
|
message
|
string
|
A mensagem de erro que indica a razão pela qual a operação falhou.
|