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

Set-AzVirtualNetworkGatewayConnection

配置虚拟网络网关连接。

语法

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>]

说明

Set-AzVirtualNetworkGatewayConnection cmdlet 配置虚拟网络网关连接。

示例

示例 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  : []

示例 2:向现有 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  : []

示例 3:将 natRules 添加到现有的 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"
                            }
                          ]

第一个命令获取名为 1 的虚拟网络网关连接,该连接属于资源组 myRG,并将其存储在名为$conn的变量中。 第二个命令获取名为 natRule1 的虚拟网络网关 natRule,并将其存储在名为 $egressNatrule 的变量中。 第三个命令设置删除了所有 IngressNatRules 的虚拟网络网关连接,并将 egressNatrule 添加到 EgressNatRules。

示例 3:将 GatewayCustomBgpIpAddress 添加到现有的 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"
                                }
                              ]

这将创建新的 AzGatewayCustomBgpIpConfigurationObjects,并使用这些 GatewayCustomBgpIpAddress 更新网关连接。

示例 4:将 GatewayCustomBgpIpAddress 删除到现有的 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 : []

这将更新网关连接,并删除这些 GatewayCustomBgpIpAddress。

参数

-AsJob

在后台运行 cmdlet

类型:SwitchParameter
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-Confirm

提示你在运行 cmdlet 之前进行确认。

类型:SwitchParameter
别名:cf
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-ConnectionMode

虚拟网络网关连接模式。

类型:String
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-DefaultProfile

用于与 Azure 通信的凭据、帐户、租户和订阅。

类型:IAzureContextContainer
别名:AzContext, AzureRmContext, AzureCredential
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-DpdTimeoutInSeconds

连接的死对等检测超时(以秒为单位)。

类型:Nullable<T>[Int32]
Position:Named
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-EgressNatRule

与此连接关联的出口 NAT 规则的列表。

类型:PSResourceId[]
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-EnableBgp

是否通过 S2S VPN 隧道使用 BGP 会话

类型:Nullable<T>[Boolean]
Position:Named
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-Force

如果想要覆盖资源,请不要要求确认

类型:SwitchParameter
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-GatewayCustomBgpIpAddress

此连接中使用的虚拟网络网关的 GatewayCustomBgpIpAddress。

类型:PSGatewayCustomBgpIpConfiguration[]
Position:Named
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-IngressNatRule

与此连接关联的入口 NAT 规则的列表。

类型:PSResourceId[]
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-IpsecPolicies

IPSec 策略的列表。

类型:PSIpsecPolicy[]
Position:Named
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-Tag

表示资源标记的哈希表。

类型:Hashtable
Position:Named
默认值:None
必需:True
接受管道输入:False
接受通配符:False

-TrafficSelectorPolicy

流量选择器策略的列表。

类型:PSTrafficSelectorPolicy[]
Position:Named
默认值:None
必需:False
接受管道输入:True
接受通配符:False

-UseLocalAzureIpAddress

是否对 S2S 连接使用 PrivateIP

类型:Nullable<T>[Boolean]
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-UsePolicyBasedTrafficSelectors

是否对 S2S 连接使用基于策略的流量选择器

类型:Nullable<T>[Boolean]
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

-VirtualNetworkGatewayConnection

The VirtualNetworkGatewayConnection

类型:PSVirtualNetworkGatewayConnection
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-WhatIf

显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。

类型:SwitchParameter
别名:wi
Position:Named
默认值:None
必需:False
接受管道输入:False
接受通配符:False

输入

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[]

输出

PSVirtualNetworkGatewayConnection