Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

Set-AzVirtualNetworkPeering

Configures a virtual network peering.

Syntax

Default (Default)

Set-AzVirtualNetworkPeering
 -VirtualNetworkPeering <PSVirtualNetworkPeering>
 [-AsJob]
 [-DefaultProfile <IAzureContextContainer>]
 [<CommonParameters>]

Description

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

# Get the virtual network peering
$myVnet1TomyVnet2 = Get-AzVirtualNetworkPeering -VirtualNetworkName "myVnet1" -ResourceGroupName "myResourceGroup" -Name "myVnet1TomyVnet2"

# Change AllowVirtualNetworkAccess property
$myVnet1TomyVnet2.AllowVirtualNetworkAccess = $False

# Update virtual network peering
Set-AzVirtualNetworkPeering -VirtualNetworkPeering $myVnet1TomyVnet2

Example 3: Change gateway transit property configuration of a virtual network peering

# Get the virtual network peering
$myVnet1TomyVnet2 = Get-AzVirtualNetworkPeering -VirtualNetworkName "myVnet1" -ResourceGroupName "myResourceGroup" -Name "myVnet1TomyVnet2"

# Change AllowGatewayTransit property
$myVnet1TomyVnet2.AllowGatewayTransit = $True

# Update the virtual network peering
Set-AzVirtualNetworkPeering -VirtualNetworkPeering $myVnet1TomyVnet2

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

-AsJob

Run cmdlet in the background

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

-VirtualNetworkPeering

Specifies the virtual network peering.

Parameter properties

Type:PSVirtualNetworkPeering
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

CommonParameters

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.

Inputs

PSVirtualNetworkPeering

Outputs

PSVirtualNetworkPeering

Related Links


Feedback

Was this page helpful?