Dela via


Set-AzVirtualNetworkGatewayConnection

Konfigurerar en anslutning till en virtuell nätverksgateway.

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

Cmdleten Set-AzVirtualNetworkGatewayConnection konfigurerar en anslutning till en virtuell nätverksgateway.

Exempel

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

Exempel 2: Lägga till/uppdatera taggar till en befintlig 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  : []

Exempel 3: Lägg till/ta bort natRules i en befintlig 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"
                            }
                          ]

Det första kommandot hämtar en virtuell nätverksgatewayanslutning med namnet 1 som tillhör resursgruppen myRG och lagrar den till variabeln med namnet $conn. Det andra kommandot hämtar den virtuella nätverksgatewayen natRule med namnet natRule1 och lagrar den till variabeln med namnet $egressNatrule. Det tredje kommandot anger anslutning till virtuell nätverksgateway med borttagna alla IngressNatRules och lägger till egressNatrule i EgressNatRules.

Exempel 3: Lägg till/ta bort gatewayCustomBgpIpAddress till en befintlig 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"
                                }
                              ]

Detta skapar nya AzGatewayCustomBgpIpConfigurationObjects och uppdaterar gatewayanslutningen med dessa GatewayCustomBgpIpAddress.

Exempel 4: Ta bort GatewayCustomBgpIpAddress till en befintlig 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 : []

Detta uppdaterar gatewayanslutningen med att ta bort dessa GatewayCustomBgpIpAddress.

Parametrar

-AsJob

Kör cmdlet i bakgrunden

Typ:SwitchParameter
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-Confirm

Uppmanar dig att bekräfta innan du kör cmdleten.

Typ:SwitchParameter
Alias:cf
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-ConnectionMode

Anslutningsläge för virtuell nätverksgateway.

Typ:String
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-DefaultProfile

Autentiseringsuppgifter, konto, klientorganisation och prenumeration som används för kommunikation med Azure.

Typ:IAzureContextContainer
Alias:AzContext, AzureRmContext, AzureCredential
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-DpdTimeoutInSeconds

Tidsgräns för död peer-identifiering av anslutningen i sekunder.

Typ:Nullable<T>[Int32]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:True
Godkänn jokertecken:False

-EgressNatRule

Listan över utgående NAT-regler som är associerade med den här anslutningen.

Typ:PSResourceId[]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-EnableBgp

Om du vill använda en BGP-session över en S2S VPN-tunnel

Typ:Nullable<T>[Boolean]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:True
Godkänn jokertecken:False

-Force

Be inte om bekräftelse om du vill skriva över en resurs

Typ:SwitchParameter
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-GatewayCustomBgpIpAddress

GatewayCustomBgpIpAddress för virtuell nätverksgateway som används i den här anslutningen.

Typ:PSGatewayCustomBgpIpConfiguration[]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:True
Godkänn jokertecken:False

-IngressNatRule

Listan över inkommande NAT-regler som är associerade med den här anslutningen.

Typ:PSResourceId[]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-IpsecPolicies

En lista över IPSec-principer.

Typ:PSIpsecPolicy[]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:True
Godkänn jokertecken:False

-Tag

En hashtable som representerar resurstaggar.

Typ:Hashtable
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-TrafficSelectorPolicy

En lista över principer för trafikväljare.

Typ:PSTrafficSelectorPolicy[]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:True
Godkänn jokertecken:False

-UseLocalAzureIpAddress

Om du vill använda PrivateIP för en S2S-anslutning

Typ:Nullable<T>[Boolean]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-UsePolicyBasedTrafficSelectors

Om du vill använda principbaserade trafikväljare för en S2S-anslutning

Typ:Nullable<T>[Boolean]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-VirtualNetworkGatewayConnection

The VirtualNetworkGatewayConnection

Typ:PSVirtualNetworkGatewayConnection
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:True
Godkänn jokertecken:False

-WhatIf

Visar vad som skulle hända om cmdleten kördes. Cmdleten körs inte.

Typ:SwitchParameter
Alias:wi
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

Indata

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

Utdata

PSVirtualNetworkGatewayConnection