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

Set-AzScheduledQueryRule

更新日志警报规则

语法

Set-AzScheduledQueryRule
   -Source <PSScheduledQueryRuleSource>
   [-Schedule <PSScheduledQueryRuleSchedule>]
   -Action <PSScheduledQueryRuleAlertingAction>
   -Location <String>
   [-Description <String>]
   -Name <String>
   -ResourceGroupName <String>
   [-Tag <Hashtable>]
   [-Enabled <Boolean>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzScheduledQueryRule
   -InputObject <PSScheduledQueryRuleResource>
   [-Source <PSScheduledQueryRuleSource>]
   [-Schedule <PSScheduledQueryRuleSchedule>]
   [-Action <PSScheduledQueryRuleAlertingAction>]
   [-Location <String>]
   [-Description <String>]
   [-Tag <Hashtable>]
   [-Enabled <Boolean>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzScheduledQueryRule
   -ResourceId <String>
   -Source <PSScheduledQueryRuleSource>
   [-Schedule <PSScheduledQueryRuleSchedule>]
   -Action <PSScheduledQueryRuleAlertingAction>
   -Location <String>
   [-Description <String>]
   [-Tag <Hashtable>]
   [-Enabled <Boolean>]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

说明

按 PUT 语义更新日志警报规则

示例

示例 1 - 按规则名称设置

PS C:\> Set-AzScheduledQueryRule -ResourceGroupName "MyResourceGroup" -Name "LogAlertRule1" -Enabled $true -Location "centralindia" -Action $alertingAction -Description "log alert description" -Schedule $schedule -Source $source

Description       : log alert description
Enabled           : true
LastUpdatedTime   : 19-Apr-19 12:45:04 PM
ProvisioningState : Succeeded
Source            : Microsoft.Azure.Management.Monitor.Models.Source
Schedule          : Microsoft.Azure.Management.Monitor.Models.Schedule
Action            : Microsoft.Azure.Management.Monitor.Models.AlertingAction
Id                : /subscriptions/ad825170-845c-47db-8f00-11978947b089/resourceGroups/MyResourceGroup/providers/microsoft.insights/scheduledqueryrules/LogAlertRule1
Name              : LogAlertRule1
Type              : microsoft.insights/scheduledqueryrules
Location          : centralindia
Tags              : {[hidden-link:/subscriptions/ad825170-845c-47db-8f00-11978947b089/resourceGroups/MyResourceGroup/providers/Microsoft.OperationalInsights/workspaces/MyWorkspace, Resource]}

示例 2 - 按输入对象设置

PS C:\> Set-AzScheduledQueryRule -InputObject $sqr -Description "changed description"

Description       : changed description
Enabled           : true
LastUpdatedTime   : 19-Apr-19 12:46:38 PM
ProvisioningState : Succeeded
Source            : Microsoft.Azure.Management.Monitor.Models.Source
Schedule          : Microsoft.Azure.Management.Monitor.Models.Schedule
Action            : Microsoft.Azure.Management.Monitor.Models.AlertingAction
Id                : /subscriptions/ad825170-845c-47db-8f00-11978947b089/resourceGroups/MyResourceGroup/providers/microsoft.insights/scheduledqueryrules/LogAlertRule1
Name              : LogAlertRule1
Type              : microsoft.insights/scheduledqueryrules
Location          : centralindia
Tags              : {[hidden-link:/subscriptions/ad825170-845c-47db-8f00-11978947b089/resourceGroups/MyResourceGroup/providers/Microsoft.OperationalInsights/workspaces/MyWorkspace, Resource]}

示例 3 - 按资源 ID 设置

PS C:\> Set-AzScheduledQueryRule -ResourceId "/subscriptions/ad825170-845c-47db-8f00-11978947b089/resourceGroups/MyResourceGroup/providers/microsoft.insights/scheduledqueryrules/LogAlertRule1" -Enabled $true -Location "centralindia" -Action $alertingAction -Description "change description again" -Schedule $schedule -Source $source

Description       : change description again
Enabled           : true
LastUpdatedTime   : 19-Apr-19 12:47:59 PM
ProvisioningState : Succeeded
Source            : Microsoft.Azure.Management.Monitor.Models.Source
Schedule          : Microsoft.Azure.Management.Monitor.Models.Schedule
Action            : Microsoft.Azure.Management.Monitor.Models.AlertingAction
Id                : /subscriptions/ad825170-845c-47db-8f00-11978947b089/resourceGroups/MyResourceGroup/providers/microsoft.insights/scheduledqueryrules/LogAlertRule1
Name              : LogAlertRule1
Type              : microsoft.insights/scheduledqueryrules
Location          : centralindia
Tags              : {[hidden-link:/subscriptions/ad825170-845c-47db-8f00-11978947b089/resourceGroups/MyResourceGroup/providers/Microsoft.OperationalInsights/workspaces/MyWorkspace, Resource]}

参数

-Action

计划的查询规则警报操作

类型:PSScheduledQueryRuleAlertingAction
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-AsJob

在后台运行 cmdlet

类型:SwitchParameter
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Confirm

提示你在运行 cmdlet 之前进行确认。

类型:SwitchParameter
别名:cf
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

类型:IAzureContextContainer
别名:AzContext, AzureRmContext, AzureCredential
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Description

此警报的说明

类型:String
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Enabled

azure 警报状态 - 有效值 - $true,$false

类型:Boolean
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-InputObject

计划查询规则资源

类型:PSScheduledQueryRuleResource
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-Location

此警报的位置

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-Name

警报名称

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-ResourceGroupName

资源组名称

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-ResourceId

资源 ID

类型:String
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-Schedule

计划的查询规则计划

类型:PSScheduledQueryRuleSchedule
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Source

计划的查询规则源

类型:PSScheduledQueryRuleSource
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-Tag

资源标记

类型:Hashtable
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-WhatIf

显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。

类型:SwitchParameter
别名:wi
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

输入

PSScheduledQueryRuleResource

String

PSScheduledQueryRuleSource

PSScheduledQueryRuleSchedule

PSScheduledQueryRuleAlertingAction

输出

PSScheduledQueryRuleResource