Azure / Azure/azure-cli

InvalidArgumentValue: --subnet: Invalid format

Open
#28,757 10 comments 0 reactions 1 assignee Claimed by @necusjz View on GitHub
act-quality-productivity-squad Auto-Assign Auto-Resolve Azure CLI Team customer-reported Network question Similar-Issue
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

### Describe the bug

I'm trying to create a private endpoint by using Azure CLI in bash terminal.
First, I read ASK subnet id by the command

```
akssubnet=$(az network vnet list --query "[?contains(id, 'aks-orgname-dev')].subnets[0].id" -o tsv)
echo $akssubnet
/subscriptions/xxxxxxxx-110f-42cf-8f82-xxxxxxxxxxb0/resourceGroups/MC_compute_aks-orgname-dev_westeurope/providers/Microsoft.Network/virtualNetworks/aks-vnet-33919582/subnets/aks-subnet
```

then I use this variable in the command
```
az network private-endpoint create \
-g MC_compute_aks-orgname-dev_westeurope \
-n postgresql-private-endpoint-orgname-dev \
--group-id postgresqlServer \
--subnet "$akssubnet" \
--nic-name postgresql-private-endpoint-orgname-dev-nic \
--private-connection-resource-id "$postgresqlid" \
--connection-name postgresql-private-endpoint-orgname-dev
```
this returns me the error
```
InvalidArgumentValue: --subnet: Invalid format: resource id should be in '/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.Network/virtualNetworks/{vnet_name}/subnets/{}' format.
```
but as you can see above, the `$akssubnet` has exactly this format

### Related command

az network private-endpoint create

### Errors

InvalidArgumentValue: --subnet: Invalid format: resource id should be in '/subscriptions/{subscription}/resourceGroups/{resource_group}/providers/Microsoft.Network/virtualNetworks/{vnet_name}/subnets/{}' format.

### Issue script & Debug output

![image](https://github.com/Azure/azure-cli/assets/9221694/0a8a6497-87d9-4247-b386-2152dc93f223)

### Expected behavior

no error because the format of the value is correct

### Environment Summary

azure-cli 2.57.0 *

core 2.57.0 *
telemetry 1.1.0

Dependencies:
msal 1.26.0
azure-mgmt-resource 23.1.0b2

### Additional context

_No response_

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.