I am trying to peer two Azure vnets with CLI, therefor I followed the tutorial Connect virtual networks with virtual network peering using the Azure CLI. But the result is always "BadRequestError: Cannot parse the request"
# Get the id for myVirtualNetwork1.
vNet1Id=$(az network vnet show \
--resource-group myResourceGroup \
--name myVirtualNetwork1 \
--query id --out tsv)
# Get the id for myVirtualNetwork2.
vNet2Id=$(az network vnet show \
--resource-group myResourceGroup \
--name myVirtualNetwork2 \
--query id \
--out tsv)
az network vnet peering create \
--name myVirtualNetwork1-myVirtualNetwork2 \
--resource-group myResourceGroup \
--vnet-name myVirtualNetwork1 \
--remote-vnet $vNet2Id \
--allow-vnet-access
--> BadRequestError: Cannot parse the request.
Anyone any idea?
The CLI commands work well on my side. I can reproduce the same error, please check if you have copied the sample exactly on your side.
For example, If you lack the
--out tsv
in the command, you will get the error.Update
It is something wrong or bug in the Azure CLI version
azure-CLI 2.16.0
because I can reproduce it with cloud shell or upgrade my local CLI version to2.16.0
but the same commands work well on my local PowerShell or Bash with Azure CLI2.11.1
.On PowerShell
On WSL
In this case, you could Install the specific version Azure CLI locally. Or you could have a look at the CLI bug report here.