Azure / Azure/azure-powershell

[Insights][Monitor] - Can't create ActivityLogAlert with an already created ActionGroup.

Open
#5,540 12 comments 0 reactions 3 assignees Claimed by @nolavime View on GitHub
act-observability-squad Monitor - Alerts Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

### Cmdlet(s)
Set-AzureRmActivityLogAlert

### PowerShell Version
Instructions: to get PowerShell version, type `$PSVersionTable` and look for the value associated with `PSVersion`

### Module Version

### OS Version
Instructions: to get OS version, type `$PSversionTable` and look for value associated with `BuildVersion`

### Description

### Debug Output
Instructions: to get Debug Output, set `$DebugPreference="Continue"` and then execute the cmdlet or script causing the issue

PS C:\WINDOWS\system32> Set-AzureRmActivityLogAlert -Location $location -Name 'MaintenanceAlert' -ResourceGroupName 'Default-ActivityLogAlerts' `
-Scope '/subscriptions/40cba20b-8e19-4f07-9042-b1b6a85fe7de' -Action $AGOnlyEmail -Condition $condition -Verbose
Set-AzureRmActivityLogAlert : Cannot bind parameter 'Action'. Cannot convert the
"Microsoft.Azure.Commands.Insights.OutputClasses.PSActionGroupResource" value of type
"Microsoft.Azure.Commands.Insights.OutputClasses.PSActionGroupResource" to type
"Microsoft.Azure.Management.Monitor.Management.Models.ActivityLogAlertActionGroup".
At line:2 char:98
+ ... ns/40cba20b-8e19-4f07-9042-b1b6a85fe7de' -Action $AGOnlyEmail -Condi ...
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-AzureRmActivityLogAlert], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Insights.ActivityLogAlert.SetAzur
eRmActivityLogAlertCommand

### Script/Steps for Reproduction

$email = New-AzureRmActionGroupReceiver -Name 'user1' -EmailReceiver -EmailAddress 'annayak@microsoft.com'
$AGOnlyEmail = Set-AzureRmActionGroup -Name 'agOnlyEmail' -ResourceGroup 'Default-ActivityLogAlerts' -ShortName 'testEmail' -Receiver $email
$condition = New-AzureRmActivityLogAlertCondition -Field 'category' -Equal 'ServiceHealth'

echo $AGOnlyEmail

Set-AzureRmActivityLogAlert -Location $location -Name 'MaintenanceAlert' -ResourceGroupName 'Default-ActivityLogAlerts' `
-Scope '/subscriptions/40cba20b-8e19-4f07-9042-b1b6a85fe7de' -Action $AGOnlyEmail -Condition $condition -Verbose

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.