Azure / Azure/azure-powershell

Show more details on errors for New-AzVirtualNetwork when there are duplicate Subnets

Open
#9,920 9 comments 0 reactions 2 assignees Claimed by @chandrasekarsrinivasan View on GitHub
act-quality-productivity-squad customer-reported feature-request Network - Virtual Network Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

## Problem
When using array object for the Subnet parameter of New-AzVirtualNetwork command. If there is a duplicate subnet (same name) we get the following error:
```
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : 'f5cdb7f6-c616-40fd-91b3-c20d05bba58c'
At line:1 char:9
+ $VNet = New-AzVirtualNetwork -Name $VNetName -ResourceGroupName $RGNa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzVirtualNetwork], NetworkCloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.NewAzureVirtualNetworkCommand
```
By enabling -Debug we can see the actual issue:
```
"error": {
"code": "InvalidRequestFormat",
"message": "Cannot parse the request.",
"details": [
{
"code": "DuplicateResourceName",
"message": "Resource /subscriptions//resourceGroups//providers/Microsoft.Network/virtualNetworks/ has two child resources with the same name (SL-App)."
}
]
}

```

## Proposed implementation details (optional)
Allow the error message to include why the command has failed instead of juts saying 400 / Bad request

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.