The Set-AzVirtualNetworkPeering cmdlet configures a virtual network peering.
Examples
Example 1: Change forwarded traffic configuration of a virtual network peering
# Get the virtual network peering you want to update information for
$myVnet1ToMyVnet2 = Get-AzVirtualNetworkPeering -VirtualNetworkName "myVnet1" -ResourceGroupName "ResourceGroup" -Name "myVnet1ToMyVnet2"
# Change value of AllowForwardedTraffic property
$myVnet1ToMyVnet2.AllowForwardedTraffic = $True
# Update the peering with changes made
Set-AzVirtualNetworkPeering -VirtualNetworkPeering $myVnet1ToMyVnet2
Example 2: Change virtual network access of a virtual network peering
Example 4: Use remote gateways in virtual network peering
# Get the virtual network peering
$myVnet1TomyVnet2 = Get-AzVirtualNetworkPeering -VirtualNetworkName "myVnet1" -ResourceGroupName "ResourceGroup001" -Name "myVnet1TomyVnet2"
# Change the UseRemoteGateways property
$myVnet1TomyVnet2.UseRemoteGateways = $True
# Update the virtual network peering
Set-AzVirtualNetworkPeering -VirtualNetworkPeering $myVnet1TomyVnet2
By changing this property to $True, your peer's VNet gateway can be used.
However, the peer VNet must have a gateway configured and AllowGatewayTransit must have a value of $True.
This property cannot be used if a gateway has already been configured.
Parameters
-AcquirePolicyToken
Acquire an Azure Policy token automatically for this resource operation.
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.