Using az network vnet list --resource-group reports empty array
az feedbackauto-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
network
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
I cannot reproduce it in Azure CLI 2.42.0.