Reputation: 160
I'm trying to add multiple email addresses, and running into issues. Each Email address has to be it's own receiver, and each receiver can only have one email address. So my logic is if I ran this code.
$emails = @($requestor,$careerSponsor,$practiceLead)
foreach ($email in $emails) {
$emailReceiver = New-AzActionGroupReceiver -EmailReceiver -EmailAddress $email -Name $email
Set-AzActionGroup -ResourceGroupName $rgName -Name budgetAG -ShortName budgetAG -Receiver $emailReceiver
}
I could update my action group with all three email addresses. However in result all I get is the last one added to the action group. I get three successful confirmations but all it is doing is replacing the one email receiver with the next one.
I can't add three email receivers to the -Receiver parameter, I get a HTTP BADREQUEST error. There's no documentation on how I can add multiple receivers. I'm allowed to do this in the portal, but apparently not through script. Any thoughts?
Upvotes: 0
Views: 1564
Reputation: 31270
Collect the receivers and pass those to the Set-AzActionGroup
$emails = @($requestor,$careerSponsor,$practiceLead)
$emailReceivers = @()
foreach ($email in $emails) {
$emailReceiver = New-AzActionGroupReceiver -EmailReceiver -EmailAddress $email -Name $email
$emailReceivers += $emailReceiver
}
Set-AzActionGroup -ResourceGroupName $rgName -Name budgetAG -ShortName budgetAG -Receiver $emailReceivers
Upvotes: 2