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

Using az network vnet list --resource-group reports empty array

Open nubgamerz opened this issue 4 years ago • 2 comments

az feedback auto-generates most of the information requested below, as of CLI version 2.0.62

Describe the bug After deploying a virtual network via IaC to a resource group, sometimes (not all the time, but some of the time), when trying to retrieve the list of Vnets in a resource group with:

az network vnet list --resource-group rgName

Reports an empty array

[]

If you specify the name and resource group of the vnet with:

az network vnet show --name vnetName --resource-group rgName

The vnet is reported correctly.

To Reproduce Deploy a virtual network using Azure Devops in Bicep.

From your local machine (or in Azure Devops Pipeline) run the following:

az network vnet list --resource-group rgName

The output is an empty array.

Expected behavior After running

az network vnet list --resource-group rgName

The output should contain all the vnets located in the resource group with their properties.

Environment summary

  • Azure Devops
  • Bicep
  • Az CLI (version 2.32.0)
  • YAML Pipelines

Additional context The empty array output happens in both Azure Devops pipelines and locally.

This doesn't occur only with vnets, I have also found this to happen with KeyVaults as well.

Eventually after redeploying the vnet a number of times (with the same code), the CLI reports the output correctly, but it does require a number of redeployments.

When retrieving the vnet list in Powershell (v7) with

Get-AzVirtualNetwork -resourceGroupName 'RgName'

It reports the output correctly. So this seems to be an issue specifically with Az CLI

nubgamerz avatar Jan 10 '22 10:01 nubgamerz

network

yonzhan avatar Jan 10 '22 12:01 yonzhan

I have probably the same issue. If I query by exact vnet name and resource group, with az network vnet show ... it does produce correct output, but when listing the vnets in the resource group, it is empty output at some times.

In this case I have 3 resource groups and each one has one vnet.

While this works

az network vnet show -n vnet1 -g group1
az network vnet show -n vnet1 -g group2
az network vnet show -n vnet1 -g group3

But this is flaky:

az network vnet list -g group1  # does produce correct output
az network vnet list -g group2  # does produce correct output
az network vnet list -g group3  # produces empty array

Edit: It happens with azure-cli 2.37.0 and 2.39.0

matejc avatar Aug 10 '22 10:08 matejc

I cannot reproduce it in Azure CLI 2.42.0.

necusjz avatar Nov 24 '22 09:11 necusjz