While working on few Azure Powershell scripts I was keep receiving an error 'BadRequest' whenever I was trying to create a new resource in Azure. I kept on trying to resolve an error but didn't find any proper solution to it. Initially the message was not much friendly so to dig down further I went through Get-Help of the cmdlet, tried debugging but I was not able to go to any conclusion to resolve the issue.
New-AzAutomationAccount : Operation returned an Invalid Status Code 'BadRequest' At line:1 char:1 + New-AzAutomationAccount -Name $automationAccount -Location $location ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [New-AzAutomationAccount], ErrorResponseException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.NewAzureAutomationAccount
In the next attempt to troubleshoot further I tested and tried to create a new Automation Account on the Azure Portal, then I came to know the Name of Automation Account which I was using has some restrictions and Azure has some strict naming convention guidelines. 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.
I tried Azure Powershell New-AzAutomationAccount with proper parameter arguments convention again as defined by Azure, command execution was successful. (Note: I even had mistyped location and it was giving same BadRequest error).
Create key vault and secrets with access policies in Microsoft Azure
Working With Azure Key Vault Using Azure PowerShell and AzureCLI
Use Key Vault secret identifier url to get the secret value using Powershell
Use a Azure VM system assigned managed identity to access Azure Key Vault
Create an Azure App registrations in Azure Active Directory using PowerShell & AzureCLI
Get started and configure with certificate-based authentication in Azure
Create a Virtual machine on Microsoft Azure
PowerShell List All Azure Resverations
Powershell get the list of Azure Reservations Virtual Machines instances
Get the list Azure Reservation Catalog with PowerShell and AzureCLI
This post first appeared on Tales From Real IT System Administrators World And Non-production Environment, please read the originial post: here