Skip to content

Commit de6014b

Browse files
Merge pull request #290671 from cherylmc/p2s-ps
SKUs -Gateway
2 parents fd6f1c0 + 84eca7c commit de6014b

File tree

5 files changed

+113
-174
lines changed

5 files changed

+113
-174
lines changed

articles/vpn-gateway/create-gateway-powershell.md

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,52 @@
11
---
2-
title: 'Create a virtual network gateway: PowerShell'
2+
title: Create a virtual network gateway - PowerShell
33
titleSuffix: Azure VPN Gateway
4-
description: Learn how to create a route-based virtual network gateway for a VPN connection to your on-premises network, or to connect virtual networks.
4+
description: Learn how to create a virtual network gateway for VPN Gateway connections using PowerShell.
55
author: cherylmc
66
ms.service: azure-vpn-gateway
77
ms.topic: how-to
8-
ms.date: 07/23/2024
8+
ms.date: 11/19/2024
99
ms.author: cherylmc
1010
ms.custom: devx-track-azurepowershell
1111
---
1212

1313
# Create a VPN gateway using PowerShell
1414

15-
This article helps you create an Azure VPN gateway using PowerShell. A VPN gateway is used when creating a VPN connection to your on-premises network. You can also use a VPN gateway to connect VNets. For more comprehensive information about some of the settings in this article, see [Create a VPN gateway - portal](tutorial-create-gateway-portal.md).
15+
This article helps you create an Azure VPN gateway using PowerShell. A VPN gateway is used when creating a VPN connection to your on-premises network. You can also use a VPN gateway to connect virtual networks. For more comprehensive information about some of the settings in this article, see [Create a VPN gateway - portal](tutorial-create-gateway-portal.md).
1616

1717
:::image type="content" source="./media/tutorial-create-gateway-portal/gateway-diagram.png" alt-text="Diagram that shows a virtual network and a VPN gateway." lightbox="./media/tutorial-create-gateway-portal/gateway-diagram-expand.png":::
1818

19-
A VPN gateway is one part of a connection architecture to help you securely access resources within a virtual network.
20-
2119
* The left side of the diagram shows the virtual network and the VPN gateway that you create by using the steps in this article.
2220
* You can later add different types of connections, as shown on the right side of the diagram. For example, you can create [site-to-site](tutorial-site-to-site-portal.md) and [point-to-site](point-to-site-about.md) connections. To view different design architectures that you can build, see [VPN gateway design](design.md).
2321

24-
The steps in this article create a virtual network, a subnet, a gateway subnet, and a route-based, zone-redundant active-active VPN gateway (virtual network gateway) using the Generation 2 VpnGw2AZ SKU. If you want to create a VPN gateway using the **Basic** SKU instead, see [Create a Basic SKU VPN gateway](create-gateway-basic-sku-powershell.md). Once the gateway creation completes, you can then create connections.
25-
26-
Active-active gateways differ from active-standby gateways in the following ways:
22+
The steps in this article create a virtual network, a subnet, a gateway subnet, and a route-based, zone-redundant active-active mode VPN gateway (virtual network gateway) using the Generation 2 VpnGw2AZ SKU. Once the gateway is created, you can configure connections.
2723

28-
* Active-active gateways have two Gateway IP configurations and two public IP addresses.
29-
* Active-active gateways have active-active setting enabled.
30-
* The virtual network gateway SKU can't be Basic or Standard.
24+
* If you want to create a VPN gateway using the **Basic** SKU instead, see [Create a Basic SKU VPN gateway](create-gateway-basic-sku-powershell.md).
25+
* We recommend that you create an active-active mode VPN gateway when possible. Active-active mode VPN gateways provide better availability and performance than standard mode VPN gateways. For more information about active-active gateways, see [About active-active mode gateways](about-active-active-gateways.md).
26+
* For information about availability zones and zone redundant gateways, see [What are availability zones](/azure/reliability/availability-zones-overview?toc=%2Fazure%2Fvpn-gateway%2Ftoc.json&tabs=azure-cli#availability-zones)?
3127

32-
For more information about active-active gateways, see [Highly Available cross-premises and VNet-to-VNet connectivity](vpn-gateway-highlyavailable.md).
33-
For more information about availability zones and zone redundant gateways, see [What are availability zones](/azure/reliability/availability-zones-overview?toc=%2Fazure%2Fvpn-gateway%2Ftoc.json&tabs=azure-cli#availability-zones)?
28+
> [!NOTE]
29+
> [!INCLUDE [AZ SKU region support note](../../includes/vpn-gateway-az-regions-support-include.md)]
3430
3531
## Before you begin
3632

3733
These steps require an Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
3834

39-
### Working with Azure PowerShell
40-
41-
[!INCLUDE [powershell](../../includes/vpn-gateway-cloud-shell-powershell-about.md)]
35+
[!INCLUDE [About PowerShell](../../includes/vpn-gateway-cloud-shell-powershell-about.md)]
4236

4337
## Create a resource group
4438

45-
Create an Azure resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup). A resource group is a logical container into which Azure resources are deployed and managed. If you're running PowerShell locally, open your PowerShell console with elevated privileges and connect to Azure using the `Connect-AzAccount` command.
39+
Create an Azure resource group using the [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup) command. A resource group is a logical container into which Azure resources are deployed and managed. If you're running PowerShell locally, open your PowerShell console with elevated privileges and connect to Azure using the `Connect-AzAccount` command.
4640

4741
```azurepowershell-interactive
4842
New-AzResourceGroup -Name TestRG1 -Location EastUS
4943
```
5044

5145
## <a name="vnet"></a>Create a virtual network
5246

53-
Create a virtual network with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). The following example creates a virtual network named **VNet1** in the **EastUS** location:
47+
If you don't already have a virtual network, create one with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork). When you create a virtual network, make sure that the address spaces you specify don't overlap any of the address spaces that you have on your on-premises network. If a duplicate address range exists on both sides of the VPN connection, traffic doesn't route the way you might expect it to. Additionally, if you want to connect this virtual network to another virtual network, the address space can't overlap with other virtual network. Take care to plan your network configuration accordingly.
48+
49+
The following example creates a virtual network named **VNet1** in the **EastUS** location:
5450

5551
```azurepowershell-interactive
5652
$virtualnetwork = New-AzVirtualNetwork `
@@ -60,11 +56,11 @@ $virtualnetwork = New-AzVirtualNetwork `
6056
-AddressPrefix 10.1.0.0/16
6157
```
6258

63-
Create a subnet configuration using the [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig) cmdlet.
59+
Create a subnet configuration using the [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig) cmdlet. The FrontEnd subnet isn't used in this exercise. You can substitute your own subnet name.
6460

6561
```azurepowershell-interactive
6662
$subnetConfig = Add-AzVirtualNetworkSubnetConfig `
67-
-Name Frontend `
63+
-Name FrontEnd `
6864
-AddressPrefix 10.1.0.0/24 `
6965
-VirtualNetwork $virtualnetwork
7066
```
@@ -77,7 +73,9 @@ $virtualnetwork | Set-AzVirtualNetwork
7773

7874
## <a name="gwsubnet"></a>Add a gateway subnet
7975

80-
The gateway subnet contains the reserved IP addresses that the virtual network gateway services use. Use the following examples to add a gateway subnet:
76+
[!INCLUDE [About GatewaySubnet with links](../../includes/vpn-gateway-about-gwsubnet-include.md)]
77+
78+
[!INCLUDE [NSG warning](../../includes/vpn-gateway-no-nsg-include.md)]
8179

8280
Set a variable for your virtual network.
8381

@@ -97,15 +95,19 @@ Set the subnet configuration for the virtual network using the [Set-AzVirtualNet
9795
$vnet | Set-AzVirtualNetwork
9896
```
9997

100-
## <a name="PublicIP"></a>Request a public IP address
98+
## <a name="PublicIP"></a>Request public IP addresses
99+
100+
A VPN gateway must have a public IP address. When you create a connection to a VPN gateway, this is the IP address that you specify. For active-active mode gateways, each gateway instance has its own public IP address resource. You first request the IP address resource, and then refer to it when creating your virtual network gateway. Additionally, for any gateway SKU ending in *AZ*, you must also specify the Zone setting. This example specifies a zone-redundant configuration because it specifies all three regional zones.
101101

102-
Each VPN gateway must have an allocated public IP address. When you create a connection to a VPN gateway, this is the IP address that you specify. In this exercise, we create an active-active zone-redundant VPN gateway environment. That means that two Standard public IP addresses are required, one for each gateway, and we must also specify the Zone setting. This example specifies a zone-redundant configuration because it specifies all 3 regional zones.
102+
The IP address is assigned to the resource when the VPN gateway is created. The only time the public IP address changes is when the gateway is deleted and re-created. It doesn't change across resizing, resetting, or other internal maintenance/upgrades of your VPN gateway.
103103

104-
Use the following examples to request a public IP address for each gateway. The allocation method must be **Static**.
104+
Use the following examples to request a static public IP address for each gateway instance.
105105

106106
```azurepowershell-interactive
107107
$gw1pip1 = New-AzPublicIpAddress -Name "VNet1GWpip1" -ResourceGroupName "TestRG1" -Location "EastUS" -AllocationMethod Static -Sku Standard -Zone 1,2,3
108-
```
108+
```
109+
110+
To create an active-active gateway (recommended), request a second public IP address:
109111

110112
```azurepowershell-interactive
111113
$gw1pip2 = New-AzPublicIpAddress -Name "VNet1GWpip2" -ResourceGroupName "TestRG1" -Location "EastUS" -AllocationMethod Static -Sku Standard -Zone 1,2,3
@@ -125,9 +127,9 @@ $gwipconfig2 = New-AzVirtualNetworkGatewayIpConfig -Name gwipconfig2 -SubnetId $
125127

126128
## <a name="CreateGateway"></a>Create the VPN gateway
127129

128-
Creating a gateway can often take 45 minutes or more, depending on the selected gateway SKU. Once the gateway is created, you can create a connection between your virtual network and another virtual network. Or, create a connection between your virtual network and an on-premises location.
130+
Creating a gateway can often take 45 minutes or more, depending on the selected gateway SKU. Once the gateway is created, you can create connection between your virtual network and your on-premises location. Or, create a connection between your virtual network and another virtual network.
129131

130-
Create a VPN gateway using the [New-AzVirtualNetworkGateway](/powershell/module/az.network/New-azVirtualNetworkGateway) cmdlet. Notice in the examples that both public IP addresses are referenced and the gateway is configured as active-active. In the example, we add the optional `-Debug` switch.
132+
Create a VPN gateway using the [New-AzVirtualNetworkGateway](/powershell/module/az.network/New-azVirtualNetworkGateway) cmdlet. Notice in the examples that both public IP addresses are referenced and the gateway is configured as active-active using the `EnableActiveActiveFeature` switch. In the example, we add the optional `-Debug` switch. If you want to create a gateway using a different SKU, see [About Gateway SKUs](about-gateway-skus.md) to determine the SKU that best fits your configuration requirements.
131133

132134
```azurepowershell-interactive
133135
New-AzVirtualNetworkGateway -Name VNet1GW -ResourceGroupName TestRG1 `
@@ -143,9 +145,9 @@ You can view the VPN gateway using the [Get-AzVirtualNetworkGateway](/powershell
143145
Get-AzVirtualNetworkGateway -Name Vnet1GW -ResourceGroup TestRG1
144146
```
145147

146-
## <a name="viewgwpip"></a>View the public IP addresses
148+
## <a name="viewgwpip"></a>View gateway IP addresses
147149

148-
To view the public IP address for your VPN gateway, use the [Get-AzPublicIpAddress](/powershell/module/az.network/Get-azPublicIpAddress) cmdlet. Example:
150+
Each VPN gateway instance is assigned a public IP address resource. To view the IP address associated with the resource, use the [Get-AzPublicIpAddress](/powershell/module/az.network/Get-azPublicIpAddress) cmdlet. Repeat for each gateway instance. Active-active gateways have a different public IP address assigned to each instance.
149151

150152
```azurepowershell-interactive
151153
Get-AzPublicIpAddress -Name VNet1GWpip1 -ResourceGroupName TestRG1
@@ -161,8 +163,8 @@ Remove-AzResourceGroup -Name TestRG1
161163

162164
## Next steps
163165

164-
Once the gateway has finished creating, you can create a connection between your virtual network and another virtual network. Or, create a connection between your virtual network and an on-premises location.
166+
Once the gateway is created, you can configure connections.
165167

166-
* [Create a site-to-site connection](vpn-gateway-create-site-to-site-rm-powershell.md)<br><br>
167-
* [Create a point-to-site connection](vpn-gateway-howto-point-to-site-rm-ps.md)<br><br>
168-
* [Create a connection to another VNet](vpn-gateway-vnet-vnet-rm-ps.md)
168+
* [Create a site-to-site connection](vpn-gateway-create-site-to-site-rm-powershell.md)
169+
* [Create a point-to-site connection](vpn-gateway-howto-point-to-site-rm-ps.md)
170+
* [Create a connection to another virtual network](vpn-gateway-vnet-vnet-rm-ps.md)

0 commit comments

Comments
 (0)