Azure – Operation returned an invalid status code ‘BadRequest’

Last week, I worked with Azure PowerShell in order to create an automation account on a customer account, but I got the following error:

PS > New-AzAutomationAccount -Name $AutomationAccount -Location “France South” -ResourceGroupName “RG_INFRA”
New-AzAutomationAccount : Operation returned an invalid status code ‘BadRequest’
Au caractère Ligne:1 : 1New-AzAutomationAccount -Name $AutomationAccount -Location “France So …

The command try to create the automation account in “France South” location in the “RG_INFRA” resource group.

The error message was not explicit because the status code indicated: ‘Bad Request’.

I switched to the Azure Portal and tried to create the automation account manually.

As explained on the portal, Azure has a strict naming convention guideline. The name can contain only letters, numbers, and hyphens. The name must start with a letter, and it must end with a letter or a number. The account name length must be from 6 to 50 characters.

After renaming the automation account variable, the creation was done successfully.

Thanks for reading! You can follow me on Twitter @PrigentNico

About Nicolas 282 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.