azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

Same CLI query (az resource list) returns different results in cloud shell vs. local

Open plzm opened this issue 4 years ago • 5 comments

This is autogenerated. Please review and update as needed.

Describe the bug

Command Name az resource list

Errors:

Local results fewer than identical query run in cloud shell.

The query run locally (including in GitHub hosted Actions runner) does not return Microsoft.Compute/virtualMachines or Microsoft.network/networkInterfaces resources that are in the RG. The same query run in cloud shell does return those resources.

To Reproduce:

Using Azure CLI 2.34.1 in both local (WSL2, Ubuntu 20.04) and cloud shell.

This exact query:

az resource list --subscription "4ca1851f-9d7a-456e-b346-1709991ecaff" -g "pz-vm-prod-eastus2" -o tsv --query '[].id'

Returns fewer results locally than in cloud shell.

Expected Behavior

Local returns all results in resource group, matches cloud shell output.

Environment Summary

Windows-10-10.0.19041-SP0
Python 3.8.9
Installer: 

azure-cli 2.34.1

Additional Context

Also I did the following repeatedly locally: az logout az cache purge az account clear and deleted ~/.azure.

Also note that I updated my computer to Python 3.10 x64, but az --version output in WSL2 still shows Python x86 3.8.9.

Adding files:

  • rg.png - showing the contents of the resource group in question, with hidden resources displayed
  • local.png - local az cli query output
  • cloud_shell.png - cloud shell az cli query output
  • az_version_local.png - local az --version
  • az_version_cloud_shell.png - cloud shell az --version
  • local_debug.txt - local az cli query output with --verbose --debug

rg

local

cloud_shell

az_version_local

az_version_cloud_shell

local_debug.txt

plzm avatar Mar 31 '22 13:03 plzm

ARM

yonzhan avatar Mar 31 '22 13:03 yonzhan

az vm list also does not return any VMs, same local environment. Tried multiple times including starting VM, stopping it, etc.

plzm avatar Mar 31 '22 16:03 plzm

Hi @plzm, I tried in local (azure-cli 2.35.0) and cloud shell (azure-cli 2.34.1) and didn't reproduce the problem. Could you share the command of creating the resources? Thanks.

cxznmhdcxz avatar Apr 01 '22 08:04 cxznmhdcxz

Hi @cxznmhdcxz, thank you for the update!

The VM in question was rolled out using this ARM template: https://raw.githubusercontent.com/plzm/azure-deploy/main/template/vm.linux.json It was rolled out in this GitHub Actions workflow run: https://github.com/plzm/azure-vm-disk-swap/runs/5770013219?check_suite_focus=true#step:9:1

Why would an artifact of the VM, though, yield different az CLI output on two different platforms, in both cases querying for the identical VM?

plzm avatar Apr 01 '22 21:04 plzm

Also: I was able to successfully retrieve the VM using an az graph query instead. This works: az graph query -q 'Resources | where type =~ "microsoft.compute/virtualmachines"' I am able to use this, so I am not blocked. Thanks again for your help.

plzm avatar Apr 01 '22 21:04 plzm