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

az commands always empty despite having VMs

Open billmccord opened this issue 8 years ago • 8 comments

Describe the bug I've encountered a very strange issue where I can use az resource list to show all of my resources and it shows me a few VMs. However, when I use az vm list I always get an empty list [] returned to me regardless of the fact that there are VMs and I can access them via the web interface. I've tried specifying the resource group, running queries, and nothing seems to make a difference. I've also experienced similar issues with az network ... commands. Some commands do work like az storage account list, az account list, and az group list.

Here is a shot of az resource list with sensitive details blurred. We can see that there are multiple Microsoft.ClassicNetwork/virtualNetworks: az_resource_list

To Reproduce az login az account set --subscription <subscription_id> az resource list az vm list

Expected behavior A JSON list of the VMs. One for each VM shown in the az resource list.

Environment summary Using 2.0.32 Azure CLI on Mac. I also tried on Windows and got the same result. I also tried using the Azure Cloud Shell and got the same result.

Additional context I have a contributor role, not an owner role. Not sure if this could be an issue, but based on the role permissions it seems like it should not be a factor.

billmccord avatar May 21 '18 04:05 billmccord

Did you have default resource group defined through az configure? you can use --debug to cross check the request payload which was sent on the wire.

yugangw-msft avatar May 21 '18 06:05 yugangw-msft

After digging in more and verifying that the behavior is the same even if I use Powershell, I finally found this documentation that seems to indicate that 'classic' resources can't be viewed via Powershell and, presumably, via the CLI either. https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-manager-deployment-model

Leaving here so that someone more familiar with the CLI can validate that this is indeed the issue and then happy for it to be closed out.

billmccord avatar May 21 '18 06:05 billmccord

Yes, @billmccord this is the case for strongly-typed commands like VM and network. They are using only the resource providers Microsoft.Compute, Microsoft.Network, Microsoft.Storage etc.

The generic resource arguments can show everything, which is why you see your ClassicX resources.

tjprescott avatar May 22 '18 14:05 tjprescott

Let us know how to get the the values for VM Classic machines details in Azure CLI ?

kgopi05 avatar Sep 28 '18 11:09 kgopi05

For classic VMs, you can use CLI 1.0

yugangw-msft avatar Sep 28 '18 16:09 yugangw-msft

i'm tried using azure cli --version 0.10.14 and getting no vm listed .

kgopi05 avatar Mar 29 '19 18:03 kgopi05

I am having this same issue with the CLI.

az account list returns my subscriptions, but no other list command returns anything. Is there a solution to fix this? I have uninstalled and reinstalled the CLI even, but I'm getting the same issue. I have owner IAM control over all these resources as well.

mgeorgebrown89 avatar Dec 05 '19 21:12 mgeorgebrown89

@mgeorgebrown89, try deleting your ~/.azure directory and run az login again. (in my case I completely re-installed the az cli, but I think only removing the .azure dir may have been sufficient.)

joshschmitter avatar Jul 29 '20 14:07 joshschmitter