你当前正在访问 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[]>]
   [-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[]>]
   -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。

参数

-AsJob

在后台运行 cmdlet

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

-Confirm

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

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

-ConnectionMode

虚拟网络网关连接模式。

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

-DefaultProfile

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

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

-DpdTimeoutInSeconds

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

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

-EgressNatRule

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

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

-EnableBgp

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

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

-Force

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

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

-IngressNatRule

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

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

-IpsecPolicies

IPSec 策略的列表。

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

-Tag

表示资源标记的哈希表。

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

-TrafficSelectorPolicy

流量选择器策略的列表。

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

-UseLocalAzureIpAddress

是否对 S2S 连接使用 PrivateIP

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

-UsePolicyBasedTrafficSelectors

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

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

-VirtualNetworkGatewayConnection

指定此 cmdlet 用于修改虚拟网络网关连接的 PSVirtualNetworkGatewayConnection 对象。

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

-WhatIf

显示在此 cmdlet 运行的情况下将会发生什么。 此 cmdlet 未运行。

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters: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[]

输出

PSVirtualNetworkGatewayConnection