I am getting the exact issue. Please post here if you get it resolved. Thank you!
Cannot run New-AzActionGroup after New-AzActionGroupReceiver
Hello,
I am trying to create a new action group using PS. The group will use webhook. To achieve this I need to create an action group receiver.
Code:
$ActionGroupShortName = 'Alert'
$ActionGroupReceiverName = 'MonitoringAlertActionGroupReceiver'
$WebhookURL = 'https://api.compnay.com/v1/json/azure?apiKey=1111-1111-111-111-111'
$ActionGroupReceiver = New-AzActionGroupReceiver -Name $ActionGroupReceiverName -WebhookReceiver -ServiceUri $WebhookURL -UseCommonAlertSchema
New-AzActionGroup -Name $ActionGroupName -ResourceGroupName $ResourceGroupName -Location $Location -GroupShortName $ActionGroupShortName
Set-AzActionGroup -ResourceGroupName $ResourceGroupName -Name $ActionGroupName -ShortName $ActionGroupShortName -Receiver @($ActionGroupReceiver)
Recently this code stopped working. I cannot use the commands New-AzActionGroupReceiver and New-AzActionGroup in the same PS session. If I run them in the same PS session the command always crashes.
I have updated the Az.Monitor module, this did not help. I use PS7.
Example 1: Run first New-AzActionGroupReceiver, New-AzActionGroup crashes:
Example 2: Run first New-AzActionGroup (canceled it), New-AzActionGroupReceiver crashes:
I am going to open a case with MS, but often I get answers here much faster.
2 answers
Sort by: Most helpful
-
-
Oleg Tserkovnyuk 661 Reputation points
2024-06-13T13:41:36.13+00:00 MS has updated the PS module, deprecated some commands, changed names and parameters for other.
New-AzActionGroup -Name $ActionGroupName -ResourceGroupName $ResourceGroupName -Location $Location -GroupShortName $ActionGroupShortName $ActionGroupReceiver = New-AzActionGroupWebhookReceiverObject -Name $ActionGroupReceiverName -ServiceUri $WebhookURL -UseCommonAlertSchema $true Update-AzActionGroup -ResourceGroupName $ResourceGroupName -Name $ActionGroupName -GroupShortName $ActionGroupShortName -WebhookReceiver @($ActionGroupReceiver) -Enabled