Cannot run New-AzActionGroup after New-AzActionGroupReceiver

Oleg Tserkovnyuk 661 Reputation points
2024-05-16T10:59:45.49+00:00

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:User's image

Example 2: Run first New-AzActionGroup (canceled it), New-AzActionGroupReceiver crashes:User's image

I am going to open a case with MS, but often I get answers here much faster.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,330 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,561 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,615 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Michele Forte 0 Reputation points
    2024-06-06T14:33:14.5633333+00:00

    I am getting the exact issue. Please post here if you get it resolved. Thank you!


  2. 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
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.