Azure / Azure/azure-cli

[BASTION] Unable to reference VNET in a different resource group

Open
#17,662 5 comments 0 reactions 0 assignees View on GitHub
act-quality-productivity-squad Doing feature-request Network Network - Bastion p1_e2 Service Attention
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

I am attempting to create a Bastion Host using an existing VNET. Instead of using the Name of the VNET, I tried to use the ID of the VNET and the ID of Bastion Subnet for the VNET Name.

CLI Version
2.21.0 (can't download 2.22.0 yet)

Command

```bash
az network bastion create \
--name BASTION_NAME \
--public-ip-address PUBLIC_IP_ADDRESS
--resource-group RESOURCE_GROUP
--vnet-name /subscriptions/XXXXX/resourceGroups/VNET_RESOURCE_GROUP/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/AzureBastionSubnet \
--location LOCATION
```

Error:

```json
"error": {
"code": "InvalidRequestFormat",
"message": "Cannot parse the request.",
"details": [
{
"code": "InvalidJsonReferenceFormat",
"message": "Reference Id /subscriptions/XXXXX/resourceGroups/RESOURCE_GROUP/providers/Microsoft.Network/virtualNetworks//subscriptions/XXXXX/resourceGroups/VNET_RESOURCE_GROUP/providers/Microsoft.Network/virtualNetworks/VNET_NAME/subnets/AzureBastionSubnet is not formatted correctly. The Id is expected to reference resources of type virtualNetworks/subnets. Path properties.ipConfigurations[0].properties.subnet."
}
]
}
```
It seems that the Subnet ID is being appended as the VNET name.

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.