Azure-cli: Vnet peering between two vnets in different resource groups

Created on 2 Nov 2018  路  5Comments  路  Source: Azure/azure-cli

Describe the bug
I am trying to creating a peering between two different vnets in different resource groups but it doesn't seem to work. I tried the command below:
_az network vnet peering create -g vnet1rg --name vnet1vnet2peer --vnet-name vnet1 --remote-vnet vnet2 --allow-vnet-access_
I get the following error message
Resource /subscriptions//resourceGroups/vnet1rg/providers/Microsoft.Network/virtualNetworks/vnet2 referenced by resource /subscriptions//resourceGroups/vnet1rg/providers/Microsoft.Network/virtualNetworks/vnet1/virtualNetworkPeerings/vnet1vnet2peer was not found. Please make sure that the referenced resource exists.

This seems to indicate that it is trying to vnet2 in the vnet1rg. So I change the resource group to vnet2rg:
_az network vnet peering create -g vnet2rg --name vnet1vnet2peer --vnet-name vnet1 --remote-vnet vnet2 --allow-vnet-access_
Then I get the following:
The Resource 'Microsoft.Network/virtualNetworks/vnet1' under resource group 'vnet2rg' was not found.

I see no provision for specifying two resource groups. Any help would be much appreciated.

To Reproduce
Try creating a peering between two vnets in different resource groups
_az network vnet peering create -g vnet1rg --name vnet1vnet2peer --vnet-name vnet1 --remote-vnet vnet2 --allow-vnet-access_
Expected behavior
Expect a peering to be created between vnet1 and vnet2

Environment summary
Azure cloud shell

question

Most helpful comment

From the help documentation, --remove-vnet accepts a name or resource ID. You need to supply the resource ID from cross-subscriptions or cross-RG scenarios.

All 5 comments

From the help documentation, --remove-vnet accepts a name or resource ID. You need to supply the resource ID from cross-subscriptions or cross-RG scenarios.

Thanks for the super quick reply. Typo in last statement, I think you mean remote-vnet

Yep, you're right :)

I have the same issue Spoke01-vnet & Hub01-vnet are in different resorce groups so what would the syntax be for Hub01-vnet

az network vnet peering create -g Spoke01-vnet-rg -n Spoke01-vnetToHub01-vnet --vnet-name Spoke01-vnet --remote-vnet Hub01-vnet --allow-vnet-access --subscription xxxxxxxx-xxxxxxxxx-xxxxxxxxxxxxxxxx

I have the same issue Spoke01-vnet & Hub01-vnet are in different resorce groups so what would the syntax be for Hub01-vnet

az network vnet peering create -g Spoke01-vnet-rg -n Spoke01-vnetToHub01-vnet --vnet-name Spoke01-vnet --remote-vnet Hub01-vnet --allow-vnet-access --subscription xxxxxxxx-xxxxxxxxx-xxxxxxxxxxxxxxxx

if both Vnet in same resource group then the above command will work if the both Vnet is in different resource group then you have to use --remote-vnet-id of the Hub01-vnet. you can get this from vnet properties

Was this page helpful?
0 / 5 - 0 ratings