次の方法で共有


New-AzureRmAutomationAccount - Error Creating Automation Account

I was working with one of the customers who had issues creating Automation Account through Azure Powershell.

We got an Error while running the following Command

New-AzureRMAutomationAccount -ResourceGroupName $ResourceGroup -Name  $AutomationAccountName -Location $Location

This was the Error:

New-AzureRMAutomationAccount : BadRequest: {"Message":"The request is invalid.","ModelState":{"account.name":["The account name is invalid.  The account name must not be empty, and must not
exceed 50 characters in length.  The account name must start with a letter or number.  The account name can contain letters, numbers, and dashes.  The final character must be a letter or a
number."]}}
At line:1 char:1
+ New-AzureRMAutomationAccount -ResourceGroupName $ResourceGroup -Name  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureRmAutomationAccount], CloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.NewAzureAutomationAccount

 

 

Looking at the command, the command itself was correct.

You can refer this for the cmdlet info: https://msdn.microsoft.com/en-us/library/mt603561.aspx

But we knew it was something related to Account name that we were giving.

We went to Azure Portal and when we tried creating the Account, we just gave the same information that we had passed into the variable $AutomationAccountName  above.

error

Then, it said the account name should be at least 6 characters.

Once we changed it in the variable, we were able to create the Automation Account without errors.

I hope it helps.