Azure / Azure/azure-cli

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

Open
#20,940 4 comments 1 reaction 1 assignee Assigned to @necusjz View on GitHub
act-quality-productivity-squad feature-request Network
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

> ### `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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.