Azure / azure-cli

Azure Command-Line Interface
MIT License
3.98k stars 2.96k forks source link

InvalidArgumentValue: --subnet: Invalid format #28757

Open Marusyk opened 5 months ago

Marusyk commented 5 months ago

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

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

azure-client-tools-bot-prd[bot] commented 5 months ago

Hi @Marusyk,

2.57.0 is not the latest Azure CLI(2.59.0).

If you haven't already attempted to do so, please upgrade to the latest Azure CLI version by following https://learn.microsoft.com/en-us/cli/azure/update-azure-cli.

azure-client-tools-bot-prd[bot] commented 5 months ago
Hi @Marusyk Find similar issue https://github.com/Azure/azure-cli/issues/11254.
Issue title Example format of --subnet-id for az redis create
Create time 2019-11-15
Comment number 0

Please confirm if this resolves your issue.

yonzhan commented 5 months ago

Thank you for opening this issue, we will look into it.

Marusyk commented 5 months ago

Upgraded to the latest version but the problem still exists image

necusjz commented 5 months ago

could you input --vnet-name {vnet} --subnet {subnet} at the same time (both using name)?

Marusyk commented 5 months ago

the problem is that the same script works in PowerShell but doesn't work in Bash. I don't want to change it or add other params. Could you please explain what is the problem in Bash?

necusjz commented 5 months ago

ah, could you please share the entire debugging log in bash (appending --debug)?

Marusyk commented 4 months ago

it works from other terminal

smereczynski commented 4 months ago

It should not be closed. I have the same problem creating NIC in ZSH.