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/
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
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
Most helpful comment
From the help documentation,
--remove-vnetaccepts a name or resource ID. You need to supply the resource ID from cross-subscriptions or cross-RG scenarios.