你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Set-AzActivityLogAlert

Creates a new or sets an existing activity log alert.

语法

SetByNameAndResourceGroup

Set-AzActivityLogAlert
    -Location <String>
    -Name <String>
    -ResourceGroupName <String>
    -Scope <System.Collections.Generic.List`1[System.String]>
    -Condition <System.Collections.Generic.List`1[Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertLeafCondition]>
    -Action <System.Collections.Generic.List`1[Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup]>
    [-DisableAlert]
    [-Description <String>]
    [-Tag <System.Collections.Generic.Dictionary`2[System.String,System.String]>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

SetByResourceId

Set-AzActivityLogAlert
    -ResourceId <String>
    [-Location <String>]
    [-Scope <System.Collections.Generic.List`1[System.String]>]
    [-Condition <System.Collections.Generic.List`1[Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertLeafCondition]>]
    [-Action <System.Collections.Generic.List`1[Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup]>]
    [-DisableAlert]
    [-Description <String>]
    [-Tag <System.Collections.Generic.Dictionary`2[System.String,System.String]>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

SetByInputObject

Set-AzActivityLogAlert
    -InputObject <PSActivityLogAlertResource>
    [-Scope <System.Collections.Generic.List`1[System.String]>]
    [-Condition <System.Collections.Generic.List`1[Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertLeafCondition]>]
    [-Action <System.Collections.Generic.List`1[Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup]>]
    [-Description <String>]
    [-Tag <System.Collections.Generic.Dictionary`2[System.String,System.String]>]
    [-DefaultProfile <IAzureContextContainer>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

说明

The Set-AzActivityLogAlert cmdlet creates a new or sets an existing activity log alert. For tags, conditions, and actions the objects must be created in advance and passed as parameters in this call as a comma separated (see the example below). This cmdlet implements the ShouldProcess pattern, i.e. it might request confirmation from the user before actually creating/modifying the resource. NOTE: This cmdlet and its related ones replaces the deprecated (November 2017) Add-AzLogAlertRule.

示例

Example 1: Create an Activity Log Alert

PS C:\>$location = 'Global'
PS C:\>$alertName = 'myAlert'
PS C:\>$resourceGroupName = 'theResourceGroupName'
PS C:\>$condition1 = New-AzActivityLogAlertCondition -Field 'field1' -Equal 'equals1'
PS C:\>$condition2 = New-AzActivityLogAlertCondition -Field 'field2' -Equal 'equals2'
PS C:\>$dict = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
PS C:\>$dict.Add('key1', 'value1')
PS C:\>$actionGrp1 = New-AzActionGroup -ActionGroupId 'actiongr1' -WebhookProperty $dict
PS C:\>Set-AzActivityLogAlert -Location $location -Name $alertName -ResourceGroupName $resourceGroupName -Scope 'scope1','scope2' -Action $actionGrp1 -Condition $condition1, $condition2

The first four commands create leaf condition and action group. The final command creates an Activity Log Alert using the condition and the action group.

Example 2: Create an Activity Log Alert disabled

PS C:\>$location = 'Global'
PS C:\>$alertName = 'myAlert'
PS C:\>$resourceGroupName = 'theResourceGroupName'
PS C:\>$condition1 = New-AzActivityLogAlertCondition -Field 'field1' -Equal 'equals1'
PS C:\>$condition2 = New-AzActivityLogAlertCondition -Field 'field2' -Equal 'equals2'
PS C:\>$dict = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
PS C:\>$dict.Add('key1', 'value1')
PS C:\>$actionGrp1 = New-AzActionGroup -ActionGroupId 'actiongr1' -WebhookProperty $dict
PS C:\>Set-AzActivityLogAlert -Location $location -Name $alertName -ResourceGroupName $resourceGroupName -Scope 'scope1','scope2' -Action $actionGrp1 -Condition $condition1, $condition2 -DisableAlert

The first four commands create leaf condition and action group. The final command creates an Activity Log Alert using the condition and the action group, but it creates the alert disabled.

Example 3: Set an activity log alert based using a value from the pipe or the InputObject parameter

PS C:\>Get-AzActivityLogAlert -Name $alertName -ResourceGroupName $resourceGroupName | Set-AzActivityLogAlert
PS C:\>$alert = Get-AzActivityLogAlert -Name $alertName -ResourceGroupName $resourceGroupName
PS C:\>$alert.Description = 'Changing the description'
PS C:\>$alert.Enabled = $false
PS C:\>Set-AzActivityLogAlert -InputObject $alert

The first command is similar to a nop, it sets the alert with the same values it already contained The rest of the commands retrieve the alert rule, change the description and disable it, then use the InputObject parameter to persist those changes

Example 4: Set an activity log alert based using the ResourceId value from the pipe

PS C:\>Get-AzResource -ResourceGroupName "myResourceGroup" -Name "myLogAlert" | Set-AzActivityLogAlert -DisableAlert

If the given log alert rule exists this command disables it.

参数

-Action

The list of action groups for the activity log alert.

参数属性

类型:

List<T>[ActivityLogAlertActionGroup]

默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Condition

The list of conditions for the activity log alert. NOTE: In the list of conditions there must be at least one with the Field equal to "Category". The backend responds with 400 (BadRequest) if this condition is not present.

参数属性

类型:

List<T>[Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertLeafCondition]

默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Confirm

Prompts you for confirmation before running the cmdlet.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure

参数属性

类型:IAzureContextContainer
默认值:None
支持通配符:False
不显示:False
别名:AzContext, AzureRmContext, AzureCredential

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Description

The description of the alert resource.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
SetByResourceId
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-DisableAlert

Allows the user to create a disabled the activity log alert. If not given, the alerts are created enabled.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False
SetByResourceId
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputObject

Sets the InputObject tags property of the call to extract the required name, and resource group name properties.

参数属性

类型:PSActivityLogAlertResource
默认值:None
支持通配符:False
不显示:False

参数集

SetByInputObject
Position:Named
必需:True
来自管道的值:True
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Location

The location where the activity log alert will exist.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Name

The name of the activity log alert.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ResourceGroupName

The name of the resource group where the alert resource is going to exist.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-ResourceId

Sets the ResourceId tags property of the call to extract the required name, resource group name properties.

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

SetByResourceId
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Scope

The list of scopes for the activity log alert.

参数属性

类型:

List<T>[String]

默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-Tag

Sets the tags property of the activity log alert resource.

参数属性

类型:

Dictionary<TKey,TValue>[System.String,System.String]

默认值:None
支持通配符:False
不显示:False

参数集

SetByNameAndResourceGroup
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False
SetByResourceId
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):True
来自剩余参数的值:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:wi

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

输入

String

List<T>

List<T>

List<T>

Dictionary<TKey,TValue>

PSActivityLogAlertResource

输出

PSActivityLogAlertResource