Remove-AzMetricAlertRuleV2
Removes a V2 (non-classic) metric alert rule.
Syntax
ByMetricRuleResourceName (Default)
Remove-AzMetricAlertRuleV2
-Name <String>
-ResourceGroupName <String>
[-PassThru]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByMetricRuleResourceId
Remove-AzMetricAlertRuleV2
-ResourceId <String>
[-PassThru]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
ByRuleObject
Remove-AzMetricAlertRuleV2
-InputObject <PSMetricAlertRuleV2>
[-PassThru]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The Remove-AzMetricAlertRuleV2 cmdlet removes an alert rule. This cmdlet implements the ShouldProcess pattern, i.e. it might request confirmation from the user before actually creating, modifying, or removing the resource.
Examples
Example 1: Remove an alert rule by name
Remove-AzMetricAlertRuleV2 -ResourceGroupName xxxxRG -Name PsSdk -PassThru
True
This command removes the alert rule named PsSdk
Example 2: Remove an alert rule by ID
Remove-AzMetricAlertRuleV2 -ResourceId /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricAlertRG/providers/Microsoft.Insights/metricAlerts/myAlertRule
This command removes the alert rule with resource ID /subscriptions/00000000-0000-0000-0000-0000000/resourceGroups/metricAlertRG/providers/Microsoft.Insights/metricAlerts/myAlertRule
Example 3: Get an alert and remove it
Get-AzMetricAlertRuleV2 -ResourceGroupName alertstest -Name sampleAlertRule | Remove-AzMetricAlertRuleV2
This command gets an alert and removes it.
Parameters
-AsJob
Run cmdlet in the background
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.
Parameter properties
Type: IAzureContextContainer
Default value: None
Supports wildcards: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
The Metric rule object
ByRuleObject
Position: Named
Mandatory: True
Value from pipeline: True
Value from pipeline by property name: False
Value from remaining arguments: False
-Name
The name of metric alert rule
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
ByMetricRuleResourceName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-PassThru
Return true upon successful deletion.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceGroupName
The ResourceGroupName
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: ResourceGroup
Parameter sets
ByMetricRuleResourceName
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ResourceId
The RuleResourceId
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Aliases: RuleResourceId
Parameter sets
ByMetricRuleResourceId
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: 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 .
Outputs