New-​Azure​Rm​Virtual​Network​Gateway​Connection

Creates a Virtual Network Gateway Connection

Syntax

New-AzureRmVirtualNetworkGatewayConnection
   [-AuthorizationKey <String>]
   -ConnectionType <String>
   [-EnableBgp <String>]
   [-Force]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-IpsecPolicies <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSIpsecPolicy]>]
   [-LocalNetworkGateway2 <PSLocalNetworkGateway>]
   -Location <String>
   -Name <String>
   [-Peer <PSPeering>]
   -ResourceGroupName <String>
   [-RoutingWeight <Int32>]
   [-SharedKey <String>]
   [-Tag <Hashtable>]
   [-UsePolicyBasedTrafficSelectors]
   -VirtualNetworkGateway1 <PSVirtualNetworkGateway>
   [-VirtualNetworkGateway2 <PSVirtualNetworkGateway>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]
New-AzureRmVirtualNetworkGatewayConnection
   [-AuthorizationKey <String>]
   -ConnectionType <String>
   [-EnableBgp <String>]
   [-Force]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-IpsecPolicies <System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSIpsecPolicy]>]
   [-LocalNetworkGateway2 <PSLocalNetworkGateway>]
   -Location <String>
   -Name <String>
   [-PeerId <String>]
   -ResourceGroupName <String>
   [-RoutingWeight <Int32>]
   [-SharedKey <String>]
   [-Tag <Hashtable>]
   [-UsePolicyBasedTrafficSelectors]
   -VirtualNetworkGateway1 <PSVirtualNetworkGateway>
   [-VirtualNetworkGateway2 <PSVirtualNetworkGateway>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]

Description

The Virtual Network Gateway Connection is the object representing the IPsec tunnel (Site-to-Site or Vnet-to-Vnet) connected to your Virtual Network Gateway in Azure.

The New-AzureRmVirtualNetworkGatewayConnection cmdlet creates the object of your connection based on Name, Resource Group Name, and Location of the connection as well as the objects of the two gateways this connection will be connecting. Also included are the Connection Type and Shared Key.

Examples

1: Create a Site-to-Site Virtual Network Gateway Connection

New-AzureRmVirtualNetworkGatewayConnection -Name "localToVpn" -ResourceGroupName "myRG" -Location "West US" -VirtualNetworkGateway1 $gw -LocalNetworkGateway2 $local -ConnectionType IPsec -SharedKey "abc123"

Creates the object of the Virtual Network Gateway Connection with the name "localToVpn" within the resource group "myRG" in location "West US" belonging to the virtual network gateway in the variable "gw" and connecting to the local network gateway in the variable "local." The connection type is "IPsec" because this is a Site-to-Site connection, and the shared key should be more complex than "abc123" but should match what is definied in the local gateway.

2: Create a Vnet-to-Vnet Virtual Network Gateway Connection

New-AzureRmVirtualNetworkGatewayConnection -Name "connectionAB" -ResourceGroupName "myRG" -Location "West US" -VirtualNetworkGateway1 $gwA -VirtualNetworkGateway2 $gwB -ConnectionType Vnet2Vnet -SharedKey "abc123"

New-AzureRmVirtualNetworkGatewayConnection -Name "connectionBA" -ResourceGroupName "myRG" -Location "West US" -VirtualNetworkGateway1 $gwB -VirtualNetworkGateway2 $gwA -ConnectionType Vnet2Vnet -SharedKey "abc123"

Creates the object of the Virtual Network Gateway Connection with the name "connectionAB" within the resource group "myRG" in location "West US" belonging to the virtual network gateway in the variable "gwA" and connecting to the virtual network gateway in the variable "gwB." The connection type is "Vnet2Vnet" because this is a Vnet-to-Vnet connection, and the shared key should be more complex than "abc123" but should match what is definied in the both connections.

Since the Connection object belongs to the first Virtual Network Gateway (gwA, here), another Virutal Network Gateway Connection must be created beloning to the second Gateway (gwB, here) and attaching to the first Gateway (gwA). This is show in the second command, where the connection is named "connectionBA."

Required Parameters

-ConnectionType
Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Location
Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Name
Type:String
Aliases:ResourceName
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-ResourceGroupName
Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-VirtualNetworkGateway1
Type:PSVirtualNetworkGateway
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-AuthorizationKey
Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-EnableBgp
Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Force
Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationAction

Specifies how this cmdlet responds to an information event.The acceptable values for this parameter are:- Continue

  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-IpsecPolicies

A list of IPSec policies.

Type:System.Collections.Generic.List`1[Microsoft.Azure.Commands.Network.Models.PSIpsecPolicy]
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-LocalNetworkGateway2
Type:PSLocalNetworkGateway
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Peer
Type:PSPeering
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-PeerId
Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-RoutingWeight
Type:Int32
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-SharedKey
Type:String
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-Tag
Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False
-UsePolicyBasedTrafficSelectors

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

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-VirtualNetworkGateway2
Type:PSVirtualNetworkGateway
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName)
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:False
Accept pipeline input:False
Accept wildcard characters:False