Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute and Network services return resource IDs with different casing #8283

Closed
thuansoldier opened this issue Jan 17, 2019 · 7 comments
Closed
Labels
Compute az vm/vmss/image/disk Network az network vnet/lb/nic/dns/etc... Service Attention This issue is responsible by Azure service team.

Comments

@thuansoldier
Copy link

thuansoldier commented Jan 17, 2019

Describe the bug
When running az network nic list --query "[?virtualMachine.id=='<ID>']" the CLI processes case-sensitive.

To Reproduce
You'd need to look up Private IP Address by VM ID

vmList=$(az vm list --query "[?location=='westus']".id -o tsv)
for vmId in $vmList; do
   echo "$vmId"
   az network nic list --query "[?virtualMachine.id=='$vmId']".ipConfigurations[].privateIpAddress
done

Expected behavior
It should not handle case-sensitive.

Environment summary
Azure CLI version 2.0.43

@tjprescott
Copy link
Member

tjprescott commented Jan 17, 2019

If I understand correctly, the issue you are experiencing is that the VM IDs that comes back from VM list and the VM IDs that are associated with the NICs have different casing. Is that right?

The global --query argument uses the JMESPath query language. The fact that it is case sensitive is a property of the query language and not under our specific control.

@tjprescott tjprescott added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Jan 17, 2019
@thuansoldier
Copy link
Author

thuansoldier commented Jan 17, 2019

@tjprescott

I tested by getting VM info using az vm list and NIC by az network nic list. The fact is that the resource ID gives case-sensitive differently

Below is from az vm list:

id": "/subscriptions/XXXXXXXX/resourceGroups/FOO-RG/providers/Microsoft.Compute/virtualMachines/vm",

and below is from az network nic list

    "virtualMachine": {
      "id": "/subscriptions/XXXXXXXX/resourceGroups/foo-rg/providers/Microsoft.Compute/virtualMachines/vm",

Look at the resource group name. With this issue, when looking up NIC using VM ID it returns null.

@tjprescott tjprescott removed the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Jan 17, 2019
@tjprescott tjprescott changed the title az network nic list is case sensitive Compute and Network services return resource IDs with different casing Jan 17, 2019
@tjprescott tjprescott added Compute Service Attention This issue is responsible by Azure service team. labels Jan 17, 2019
@thuansoldier
Copy link
Author

thuansoldier commented Jan 17, 2019

A workaround (perharp specific to my case to query private IP address) is to go with NIC resource ID and networkProfile property as follows:

vmNicId=$(az vm list --query "[?location=='westus']".networkProfile.networkInterfaces[].id -o tsv)
for nicId in $vmNicId; do
   echo "$nicId"
   az network nic list --query "[?id=='$nicId']".ipConfigurations[].privateIpAddress
done

It returned expected result without case-sensitive issue

@tjprescott
Copy link
Member

tjprescott commented Jan 17, 2019

Thanks @thuansoldier. I'll keep this issue open as the services should ideally be returning consistent casing for resource IDs.

@mozehgir mozehgir added Compute az vm/vmss/image/disk Network az network vnet/lb/nic/dns/etc... and removed Compute labels Jul 26, 2019
@mmyyrroonn mmyyrroonn added this to Wait for Service Team in Network Features Aug 19, 2019
@haroldrandom haroldrandom added Compute-cli Network-cli Service Attention This issue is responsible by Azure service team. labels Oct 25, 2019
@mmyyrroonn mmyyrroonn added the Network az network vnet/lb/nic/dns/etc... label Feb 18, 2020
@msftbot
Copy link

msftbot bot commented Feb 18, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @aznetsuppgithub

@mmyyrroonn mmyyrroonn added the Compute az vm/vmss/image/disk label Feb 18, 2020
@msftbot
Copy link

msftbot bot commented Feb 18, 2020

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @mjconnection, @Drewm3

@Drewm3
Copy link
Member

Drewm3 commented Feb 18, 2020

The name of the resource groups returned through a VM List operation will always be upper-cased. This is the currently designed and expected behavior for VM List when no resource group is provided. When a resource group is provided then the response will use the casing of the resource group that was provided in the API.

The Resource URIs are not case sensitive. So when comparing any two resource URIs to determine if they are the same resource, then we recommend using a to_upper() or to_lower() function to get consistent casing of the URIs before the compare. Azure does not support two URIs that are exactly the same except for casing.

@Drewm3 Drewm3 closed this as completed Feb 18, 2020
Network Features automation moved this from Wait for Service Team to Done Feb 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compute az vm/vmss/image/disk Network az network vnet/lb/nic/dns/etc... Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

7 participants