Share via

The error message with "Bad request" when using Powershell Command(Set-Azactiongroup)

Tony Chen 0 Reputation points
2023-09-22T07:52:52.45+00:00

For my purpose, i am going to add a new receiver to existed action group.

First, I use Get-Azactiongroup to get existed action group's information.

Then, Use New-AzActionGroupReceiver to create a new receiver.

After create new receiver, Add this User to action group's information.

Finally, Use Set-AzActionGroup with -InputObject to update.

$actiongroup = get-azactiongroup -resourcegroupname test-01 -name pwsh-action-03
$receiver = New-AzActionGroupReceiver -Name User -EmailReceiver -EmailAddress ******@123.com
$actiongroup.EmailReceivers.Add($receiver)
Set-AzActionGroup -InputObject $actiongroup

For my situation, The platform i using is Windows Powershell, Azure Portal and MacOS termial Powershell.

When i excute commands, it is normal success on MacOS's Powershell.

The Error only happen when i use Windows or Azure Portal.

Platform Version
Windows 5&7.3.7
Powershell MacOS Terminal 7.3.6
Azure Portal 7.3.6

Error message:

Set-AzActionGroup: Exception type: ErrorResponseException, Message: Microsoft.Azure.Management.Monitor.Models.ErrorResponseException: Operation returned an invalid status code 'BadRequest'
   at Microsoft.Azure.Management.Monitor.ActionGroupsOperations.CreateOrUpdateWithHttpMessagesAsync(String resourceGroupName, String actionGroupName, ActionGroupResource actionGroup, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.Management.Monitor.ActionGroupsOperationsExtensions.CreateOrUpdateAsync(IActionGroupsOperations operations, String resourceGroupName, String actionGroupName, ActionGroupResource actionGroup, CancellationToken cancellationToken)
   at Microsoft.Azure.Management.Monitor.ActionGroupsOperationsExtensions.CreateOrUpdate(IActionGroupsOperations operations, String resourceGroupName, String actionGroupName, ActionGroupResource actionGroup)
   at Microsoft.Azure.Commands.Insights.ActionGroups.SetAzureRmActionGroupCommand.ProcessRecordInternal()
   at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet(), Code: Null, Status code:Null, Reason phrase: Null
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

1 answer

Sort by: Most helpful
  1. Limitless Technology 45,241 Reputation points
    2023-09-25T07:47:35.4166667+00:00

    Hello,

    Thank you for your question and reaching out. I can understand you are having issues related to Powershell

    Try running the commands using the Azure CLI in Windows PowerShell to see if you encounter the same error. This can help narrow down whether the issue is specific to the Az module or if it's a broader PowerShell issue.

    Check the Azure Service Health for any ongoing issues or outages that might be affecting the operation.

    and see it helps.

    Thank you

    --If the reply is helpful, please Upvote and Accept as answer--

    Was this answer helpful?


Your answer

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