azureazure-virtual-networkvnet

Virtual network peering error via powershelll


I am attempting to create a virtual network peering with remote vnet and allow vnet access to my peering. So, I tried to create it but got stuck with the error.

Code: az network vnet peering create --name peering1 --resource-group xxxx--vnet-name xxxx --remote-vnet xxxx --allow-vnet-access

Error:

az : ERROR: (ChangingRemoteVirtualNetworkNotAllowed) Changing RemoteVirtualNetwork property from Id: 
/subscriptions/xxxxxxx/resourceGroups/xxxxxx/providers/Microsoft.Network/virtualNetworks/xxxxxx
At line:2 char:1
+ az network vnet peering create --name peering1 --resource-group "xxxx ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (ERROR: (Changin...works/xxxxx:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 
AddressSpace: 
ResourceGuid: xxxxxx
ProvisioningState: Succeeded
CreatedTime: 0001-01-01T00:00:00.0000000
LastModifiedTime: 0001-01-01T00:00:00.0000000
Prefix, Subnet.Name
None
Subnet details:
Prefix, Ipconfig.IsReferenceStub, Ipconfig.PrivateIPAddress, Ipconfig.Id

None
Subnet details:
Prefix, Ipconfig.IsReferenceStub, Ipconfig.PrivateIPAddress, Ipconfig.Id
None
CloudServices:
GreKey: 0
GreKeyAllocationId: 00000000-0000-0000-0000-000000000000
GreKeyAllocationServiceUri: 
IDnsAclZoneId: 
RegionId: 0
VnetFlowLogConfiguration: null
ExtendedLocation:  of a peering is not allowed. Delete and re-create the peering with new RemoteVirtualNetwork value instead. Peering id: /subscriptions/xxxxxx/resourceGroups/xxxxxx/providers/Microsoft.Network/virtualNetworks/xxxx/virtualNetworkPeerings/xxxxx.
Code: ChangingRemoteVirtualNetworkNotAllowed
Message: Changing RemoteVirtualNetwork property from Id: 
/subscriptions/xxxxxx/resourceGroups/xxxxx/providers/Microsoft.Network/virtualNetworks/xxxx
AddressSpace: 
ResourceGuid: xxxxxx
ProvisioningState: Succeeded
CreatedTime: 0001-01-01T00:00:00.0000000
LastModifiedTime: 0001-01-01T00:00:00.0000000
Prefix, Subnet.Name
None
Subnet details:
Prefix, Ipconfig.IsReferenceStub, Ipconfig.PrivateIPAddress, Ipconfig.Id

None
CloudServices:
GreKey: 0
GreKeyAllocationId: 00000000-0000-0000-0000-000000000000
GreKeyAllocationServiceUri: 
IDnsAclZoneId: 
RegionId: 0
VnetFlowLogConfiguration: null
ExtendedLocation:  of a peering is not allowed. Delete and re-create the peering with new RemoteVirtualNetwork value instead. Peering id: /subscriptions/xxxxxx/resourceGroups/xxxxxxproviders/Microsoft.Network/virtualNetworks/xxxx/virtualNetworkPeerings/xxxx.

I re-checked all the provided values and are correct and I am passing valid values for all the parameters in az network vnet peering create command resource group, VNets, and other identifiers and verified.

Not sure where I am going wrong help me to resolve the error Thank you.


Solution

  • When I tried the same, I got the same error like below:

    enter image description here

    The error usually occurs if the vnet peering is already present in the virtual networks and make sure you are using virtual network with different address space.

    Created two virtual networks with different address space like below.

    enter image description here enter image description here

    Now when I ran the same command, I got result successfully like below:

    az network vnet peering create --name peering1 --resource-group <RGName> --vnet-name <VnetName> --remote-vnet <RemotevnetName> --allow-vnet-access`
    

    Output:

    enter image description here

    When I check the vnet peering its show all the details like below:

    az network vnet peering show -g <MyResourceGroup> -n <Vnetpeering Name> --vnet-name <MyVnet>
    

    enter image description here

    Reference:

    az network vnet peering | Microsoft Learn