Azure / Azure/azure-powershell
[Insights][Monitor] - Can't create ActivityLogAlert with an already created ActionGroup.
- 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
Assessment
This issue has not been assessed yet.