你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Set-AzVirtualNetworkGatewayConnection

Configures a virtual network gateway connection.

Syntax

Set-AzVirtualNetworkGatewayConnection
   -VirtualNetworkGatewayConnection <PSVirtualNetworkGatewayConnection>
   [-EnableBgp <Boolean>]
   [-DpdTimeoutInSeconds <Int32>]
   [-ConnectionMode <String>]
   [-UsePolicyBasedTrafficSelectors <Boolean>]
   [-UseLocalAzureIpAddress <Boolean>]
   [-IpsecPolicies <PSIpsecPolicy[]>]
   [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
   [-IngressNatRule <PSResourceId[]>]
   [-EgressNatRule <PSResourceId[]>]
   [-GatewayCustomBgpIpAddress <PSGatewayCustomBgpIpConfiguration[]>]
   [-Force]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
Set-AzVirtualNetworkGatewayConnection
   -VirtualNetworkGatewayConnection <PSVirtualNetworkGatewayConnection>
   [-EnableBgp <Boolean>]
   [-DpdTimeoutInSeconds <Int32>]
   [-ConnectionMode <String>]
   [-UsePolicyBasedTrafficSelectors <Boolean>]
   [-UseLocalAzureIpAddress <Boolean>]
   [-IpsecPolicies <PSIpsecPolicy[]>]
   [-TrafficSelectorPolicy <PSTrafficSelectorPolicy[]>]
   [-IngressNatRule <PSResourceId[]>]
   [-EgressNatRule <PSResourceId[]>]
   [-GatewayCustomBgpIpAddress <PSGatewayCustomBgpIpConfiguration[]>]
   -Tag <Hashtable>
   [-Force]
   [-AsJob]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The Set-AzVirtualNetworkGatewayConnection cmdlet configures a virtual network gateway connection.

Examples

Example 1:

$conn = Get-AzVirtualNetworkGatewayConnection -Name 1 -ResourceGroupName myRG
Set-AzVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $conn

Confirm
Are you sure you want to overwrite resource '1'
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y


Name                    : 1
ResourceGroupName       : myRG
Location                : westus
Id                      : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Mi
                          crosoft.Network/connections/1
Etag                    : W/"00000000-0000-0000-0000-000000000000"
ResourceGuid            : 00000000-0000-0000-0000-000000000000
ProvisioningState       : Succeeded
Tags                    :
AuthorizationKey        :
VirtualNetworkGateway1  : "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/M
                          icrosoft.Network/virtualNetworkGateways/myGateway"
VirtualNetworkGateway2  : "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/S2SVnetConn/providers/Mic
                          rosoft.Network/virtualNetworkGateways/S2SConnGW"
LocalNetworkGateway2    :
Peer                    :
RoutingWeight           : 0
SharedKey               :
ConnectionStatus        : Connected
EgressBytesTransferred  : 91334484
IngressBytesTransferred : 100386089
TunnelConnectionStatus  : []

Example 2: Add/Update tags to an existing VirtualNetworkGatewayConnection

$conn = Get-AzVirtualNetworkGatewayConnection -Name 1 -ResourceGroupName myRG
Set-AzVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $conn -Tag @{ testtagKey="SomeTagKey"; testtagValue="SomeKeyValue" }

Confirm
Are you sure you want to overwrite resource '1'
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y


Name                    : 1
ResourceGroupName       : myRG
Location                : westus
Id                      : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Mi
                          crosoft.Network/connections/1
Etag                    : W/"00000000-0000-0000-0000-000000000000"
ResourceGuid            : 00000000-0000-0000-0000-000000000000
ProvisioningState       : Succeeded
Tags                    :
                          Name          Value
                          ============  ============
                          testtagValue  SomeKeyValue
                          testtagKey    SomeTagKey
AuthorizationKey        :
VirtualNetworkGateway1  : "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/M
                          icrosoft.Network/virtualNetworkGateways/myGateway"
VirtualNetworkGateway2  : "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/S2SVnetConn/providers/Mic
                          rosoft.Network/virtualNetworkGateways/S2SConnGW"
LocalNetworkGateway2    :
Peer                    :
RoutingWeight           : 0
SharedKey               :
ConnectionStatus        : Connected
EgressBytesTransferred  : 91334484
IngressBytesTransferred : 100386089
TunnelConnectionStatus  : []

Example 3: Add/Remove natRules to an existing VirtualNetworkGatewayConnection

$conn = Get-AzVirtualNetworkGatewayConnection -Name 1 -ResourceGroupName myRG
$egressNatrule = Get-AzVirtualNetworkGatewayNatRule -ResourceGroupName myRG -Name "natRule1" -ParentResourceName "gw1"
Set-AzVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $conn -IngressNatRule @() -EgressNatRule $egressNatrule

Confirm
Are you sure you want to overwrite resource '1'
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y


Name                    : 1
ResourceGroupName       : myRG
Location                : westus
Id                      : /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Mi
                          crosoft.Network/connections/1
Etag                    : W/"00000000-0000-0000-0000-000000000000"
ResourceGuid            : 00000000-0000-0000-0000-000000000000
ProvisioningState       : Succeeded
Tags                    :
                          Name          Value
                          ============  ============
                          testtagValue  SomeKeyValue
                          testtagKey    SomeTagKey
AuthorizationKey        :
VirtualNetworkGateway1  : "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/M
                          icrosoft.Network/virtualNetworkGateways/myGateway"
VirtualNetworkGateway2  : "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/S2SVnetConn/providers/Mic
                          rosoft.Network/virtualNetworkGateways/S2SConnGW"
LocalNetworkGateway2    :
Peer                    :
RoutingWeight           : 0
SharedKey               :
ConnectionStatus        : Connected
EgressBytesTransferred  : 91334484
IngressBytesTransferred : 100386089
TunnelConnectionStatus  : []
IngressNatRules         : []
EgressNatRules          : [
                            {
                              "Id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.Network/virtualNetworkGateways/gw1/natRules/natRule1"
                            }
                          ]

The first command gets a virtual network gateway connection named 1 that belongs to resource group myRG and stores it to the variable named $conn. The second command gets the virtual network gateway natRule named natRule1 and stores it to the variable named $egressNatrule. The third command sets virtual network gateway connection with removed all IngressNatRules and add egressNatrule into EgressNatRules.

Example 3: Add/Remove GatewayCustomBgpIpAddress to an existing VirtualNetworkGatewayConnection

$address1 = New-AzGatewayCustomBgpIpConfigurationObject -IpConfigurationId "/subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/virtualNetworkGateways/testGw/ipConfigurations/default" -CustomBgpIpAddress "169.254.21.1"
$address2 = New-AzGatewayCustomBgpIpConfigurationObject -IpConfigurationId "/subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/virtualNetworkGateways/testGw/ipConfigurations/ActiveActive" -CustomBgpIpAddress "169.254.21.3"
$conn = Get-AzVirtualNetworkGatewayConnection -ResourceGroupName PS_testing -ResourceName Conn
 
Set-AzVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $conn -GatewayCustomBgpIpAddress $address1,$address2

Name                        : Conn
ResourceGroupName           : PS_testing
Location                    : eastus
Id                          : /subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/connections/Conn
Etag                        : W/"e867e7bb-fa2e-436e-8822-70c556ec0f03"
ResourceGuid                : 9c33f4f7-b09c-4080-932e-a44405a8c252
ProvisioningState           : Succeeded
Tags                        :
AuthorizationKey            :
VirtualNetworkGateway1      : "/subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/virtualNetworkGateways/testGw"
VirtualNetworkGateway2      :
LocalNetworkGateway2        : "/subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/localNetworkGateways/testLng"
Peer                        :
RoutingWeight               : 3
SharedKey                   : abc
ExpressRouteGatewayBypass   : False
EnablePrivateLinkFastPath   : False
ConnectionStatus            : Unknown
EgressBytesTransferred      : 0
IngressBytesTransferred     : 0
TunnelConnectionStatus      : []
IngressNatRules             : []
EgressNatRules              : []
GatewayCustomBgpIpAddresses : [
                                {
                                  "IpconfigurationId":
                              "/subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/virtualNetworkGateways/testGw/ipConfigurations/default",
                                  "CustomBgpIpAddress": "169.254.21.1"
                                },
                                {
                                  "IpconfigurationId":
                              "/subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/virtualNetworkGateways/testGw/ipConfigurations/ActiveActive",
                                  "CustomBgpIpAddress": "169.254.21.3"
                                }
                              ]

This will create new AzGatewayCustomBgpIpConfigurationObjects and update gateway connection with these GatewayCustomBgpIpAddress.

Example 4: Remove GatewayCustomBgpIpAddress to an existing VirtualNetworkGatewayConnection

$conn = Get-AzVirtualNetworkGatewayConnection -ResourceGroupName PS_testing -ResourceName Conn
Set-AzVirtualNetworkGatewayConnection -VirtualNetworkGatewayConnection $conn -GatewayCustomBgpIpAddress @()

Name                      : Conn
ResourceGroupName         : PS_testing
Location                  : eastus
Id                        : /subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/connections/Conn
Etag                      : W/"863d9b89-a030-42ba-9f71-58d5bc3336a9"
ResourceGuid              : 9c33f4f7-b09c-4080-932e-a44405a8c252
ProvisioningState         : Succeeded
Tags                      :
AuthorizationKey          :
VirtualNetworkGateway1    : "/subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/virtualNetworkGateways/testGw"
VirtualNetworkGateway2    :
LocalNetworkGateway2      : "/subscriptions/83704d68-d560-4c67-b1c7-12404db89dc3/resourceGroups/PS_testing/providers/Microsoft.Network/localNetworkGateways/testLng"
Peer                      :
RoutingWeight             : 3
SharedKey                 : abc
ExpressRouteGatewayBypass : False
EnablePrivateLinkFastPath : False
ConnectionStatus          : NotConnected
EgressBytesTransferred    : 0
IngressBytesTransferred   : 0
TunnelConnectionStatus    : []
IngressNatRules           : []
EgressNatRules            : []
GatewayCustomBgpIpAddresses : []

This will update gateway connection with removing these GatewayCustomBgpIpAddress.

Parameters

-AsJob

Run cmdlet in the background

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ConnectionMode

Virtual Network Gateway Connection Mode.

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

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

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DpdTimeoutInSeconds

Dead Peer Detection Timeout of the connection in seconds.

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-EgressNatRule

The list of egress NAT rules that are associated with this Connection.

Type:PSResourceId[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-EnableBgp

Whether to use a BGP session over a S2S VPN tunnel

Type:Nullable<T>[Boolean]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Force

Do not ask for confirmation if you want to overwrite a resource

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-GatewayCustomBgpIpAddress

The GatewayCustomBgpIpAddress of Virtual network gateway used in this connection.

Type:PSGatewayCustomBgpIpConfiguration[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-IngressNatRule

The list of ingress NAT rules that are associated with this Connection.

Type:PSResourceId[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-IpsecPolicies

A list of IPSec policies.

Type:PSIpsecPolicy[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Tag

A hashtable which represents resource tags.

Type:Hashtable
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-TrafficSelectorPolicy

A list of traffic selector policies.

Type:PSTrafficSelectorPolicy[]
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-UseLocalAzureIpAddress

Whether to use PrivateIP for a S2S connection

Type:Nullable<T>[Boolean]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-UsePolicyBasedTrafficSelectors

Whether to use policy-based traffic selectors for a S2S connection

Type:Nullable<T>[Boolean]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-VirtualNetworkGatewayConnection

The VirtualNetworkGatewayConnection

Type:PSVirtualNetworkGatewayConnection
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

PSVirtualNetworkGatewayConnection

Nullable<T>[[System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

Nullable<T>[[System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]

PSIpsecPolicy[]

PSTrafficSelectorPolicy[]

PSGatewayCustomBgpIpConfiguration[]

Outputs

PSVirtualNetworkGatewayConnection