I got the following error message in PowerShell, as I was trying to create an Azure virtual network with multiple subnets by running New-AzureRMVirtualNetwork
New-AzureRmVirtualNetwork : Cannot parse the request.
ReasonPhrase: Bad Request
OperationID : ‘ac4d152b-3cbb-4087-a5b9-ef4554444334’
This error message is too vague and need more information. So where do I look?
There are two options.
1) The long and manual option
Go to Azure Portal > the target Resource Group > Activity Log
From the error message output, copy the OperationID and paste into the search box
Click on the resulting log item
Click on JSON tab, search within text by the operation ID
In the “statusMessage”, I scroll to the right and I find the detailed error message in the “statusMessage” field:
“.. has two child resources with the same name (frontendSubnet)”
2) The quick and scripted option
Add the –Debug switch to the line of PowerShell
You will get more information and even the detailed error message.
My issue was that I had multiple subnets with the same name due to cut and paste of reusing commandlet lines.
If you still want to see the JSON details in the Activity Log using Azure PowerShell, you can use the commandlet Get-AzureRMLog
So by getting the correlation ID from the x-ms-correlation-request-id HTTP header in the debug output, you pass it as a parameter as follows:
Get-AzureRmLog -CorrelationId ‘6119fdb9-1809-4b86-9ae0-415f47f684af’
By updating my PowerShell script as follows and issue is resolved.
$wafSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name wafSubnet -AddressPrefix "10.1.0.0/24"
$webSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name webSubnet -AddressPrefix "10.1.1.0/24"
$dataSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name dataSubnet -AddressPrefix "10.1.4.0/24"
$batchSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name batchSubnet -AddressPrefix "10.1.3.0/24"
$gatewaySubnet = New-AzureRmVirtualNetworkSubnetConfig -Name ‘GatewaySubnet’ -AddressPrefix "10.1.5.0/24"