Remove-AzMetricAlertRuleV2

Removes a V2 (non-classic) metric alert rule.

Syntax

Remove-AzMetricAlertRuleV2
      -Name <String>
      -ResourceGroupName <String>
      [-PassThru]
      [-AsJob]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Remove-AzMetricAlertRuleV2
      -ResourceId <String>
      [-PassThru]
      [-AsJob]
      [-DefaultProfile <IAzureContextContainer>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
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

PS C:\> Remove-AzMetricAlertRuleV2 -ResourceGroupName xxxxRG -Name PsSdk -PassThru
True

This command removes the alert rule named PsSdk

Example 2: Remove an alert rule by ID

PS C:\>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

PS c:\>Get-AzMetricAlertRuleV2 -ResourceGroupName alertstest -Name sampleAlertRule |Remove-AzMetricAlertRuleV2

This command gets an alert and removes it.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InputObject

The Metric rule object

Type:Microsoft.Azure.Commands.Insights.OutputClasses.PSMetricAlertRuleV2
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-Name

The name of metric alert rule

Type:String
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-PassThru

Return true upon successful deletion.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ResourceGroupName

The ResourceGroupName

Type:String
Aliases:ResourceGroup
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ResourceId

The RuleResourceId

Type:String
Aliases:RuleResourceId
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

Inputs

String

Microsoft.Azure.Commands.Insights.OutputClasses.PSMetricAlertRuleV2

Outputs

Boolean