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