Skip to content

Commit 3d61b02

Browse files
authored
Merge pull request #281076 from cherylmc/ps-basic
VPN Gateway create Basic SKU gateway
2 parents 9d15ff2 + e21e732 commit 3d61b02

File tree

4 files changed

+157
-0
lines changed

4 files changed

+157
-0
lines changed

articles/vpn-gateway/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@
7373
href: create-routebased-vpn-gateway-powershell.md
7474
- name: Azure CLI
7575
href: create-routebased-vpn-gateway-cli.md
76+
- name: Create a Basic SKU gateway
77+
href: create-gateway-basic-sku-powershell.md
7678
- name: Verify a gateway connection
7779
href: vpn-gateway-verify-connection-resource-manager.md
7880
- name: Reset a connection or a gateway
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
---
2+
title: 'Create a Basic SKU virtual network gateway: PowerShell'
3+
titleSuffix: Azure VPN Gateway
4+
description: Learn how to create a Basic SKU virtual network gateway for a VPN connection to your on-premises network, or to connect virtual networks. Use these instructions to create either a policy-based, or route-based VPN gateway.
5+
author: cherylmc
6+
ms.service: vpn-gateway
7+
ms.topic: how-to
8+
ms.date: 07/17/2024
9+
ms.author: cherylmc
10+
ms.custom: devx-track-azurepowershell
11+
---
12+
13+
# Create a Basic SKU VPN gateway using PowerShell
14+
15+
This article helps you create a Basic SKU Azure VPN gateway using PowerShell. The VPN gateway you create can be either RouteBased, or PolicyBased, depending on your connection requirements. 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.
16+
17+
:::image type="content" source="./media/create-gateway-basic-sku/gateway-diagram.png" alt-text="Diagram that shows a virtual network and a VPN gateway." lightbox="./media/create-gateway-basic-sku/gateway-diagram-expand.png":::
18+
19+
* The left side of the diagram shows the virtual network and the VPN gateway that you create by using the steps in this article.
20+
* 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).
21+
22+
The steps in this article create a virtual network, a subnet, a gateway subnet, and a VPN gateway (virtual network gateway) using the Basic SKU. The article steps specify a **RouteBased** VPN type. You can also specify a **PolicyBased** VPN type using the steps in this article. Once the gateway creation completes, you can then create connections. If you want to create a gateway using a SKU other than the Basic SKU, see the [Portal article](tutorial-create-gateway-portal.md).
23+
24+
Basic SKU VPN gateways have limitations. For more information about SKUs and Basic SKU limitations, see [About gateway SKUs](about-gateway-skus.md). A few of the limitations that affect the settings used in this article are:
25+
26+
* A Basic SKU VPN gateway must use the Dynamic allocation method for public IP address, not Static.
27+
* A Basic SKU VPN gateway uses a Basic SKU public IP address, not Standard.
28+
* You can't create a Basic SKU VPN gateway using the Azure portal.
29+
30+
## Before you begin
31+
32+
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.
33+
34+
### Working with Azure PowerShell
35+
36+
[!INCLUDE [powershell](../../includes/vpn-gateway-cloud-shell-powershell-about.md)]
37+
38+
## Create a resource group
39+
40+
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.
41+
42+
```azurepowershell-interactive
43+
New-AzResourceGroup -Name TestRG1 -Location EastUS
44+
```
45+
46+
## <a name="vnet"></a>Create a virtual network
47+
48+
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:
49+
50+
```azurepowershell-interactive
51+
$virtualnetwork = New-AzVirtualNetwork `
52+
-ResourceGroupName TestRG1 `
53+
-Location EastUS `
54+
-Name VNet1 `
55+
-AddressPrefix 10.1.0.0/16
56+
```
57+
58+
Create a subnet configuration using the [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig) cmdlet.
59+
60+
```azurepowershell-interactive
61+
$subnetConfig = Add-AzVirtualNetworkSubnetConfig `
62+
-Name Frontend `
63+
-AddressPrefix 10.1.0.0/24 `
64+
-VirtualNetwork $virtualnetwork
65+
```
66+
67+
Set the subnet configuration for the virtual network using the [Set-AzVirtualNetwork](/powershell/module/az.network/Set-azVirtualNetwork) cmdlet.
68+
69+
```azurepowershell-interactive
70+
$virtualnetwork | Set-AzVirtualNetwork
71+
```
72+
73+
## <a name="gwsubnet"></a>Add a gateway subnet
74+
75+
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+
77+
Set a variable for your virtual network.
78+
79+
```azurepowershell-interactive
80+
$vnet = Get-AzVirtualNetwork -ResourceGroupName TestRG1 -Name VNet1
81+
```
82+
83+
Create the gateway subnet using the [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/Add-azVirtualNetworkSubnetConfig) cmdlet.
84+
85+
```azurepowershell-interactive
86+
Add-AzVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix 10.1.255.0/27 -VirtualNetwork $vnet
87+
```
88+
89+
Set the subnet configuration for the virtual network using the [Set-AzVirtualNetwork](/powershell/module/az.network/Set-azVirtualNetwork) cmdlet.
90+
91+
```azurepowershell-interactive
92+
$vnet | Set-AzVirtualNetwork
93+
```
94+
95+
## <a name="PublicIP"></a>Request a public IP address
96+
97+
Each VPN gateway must have an allocated public IP address. At this time, Basic SKU VPN gateways still use **Dynamic** allocation method public IP address and the **Basic** public IP address SKU. These requirements are different from other VPN Gateway SKUs.
98+
99+
```azurepowershell-interactive
100+
$gwpip = New-AzPublicIpAddress -Name "VNet1GWIP" -ResourceGroupName "TestRG1" -Location "EastUS" -AllocationMethod Dynamic -Sku Basic
101+
```
102+
103+
## <a name="GatewayIPConfig"></a>Create the gateway IP address configuration
104+
105+
The gateway configuration defines the subnet and the public IP address to use. Use the following example to create your gateway configuration.
106+
107+
```azurepowershell-interactive
108+
$vnet = Get-AzVirtualNetwork -Name VNet1 -ResourceGroupName TestRG1
109+
$subnet = Get-AzVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $vnet
110+
$gwipconfig = New-AzVirtualNetworkGatewayIpConfig -Name gwipconfig -SubnetId $subnet.Id -PublicIpAddressId $gwpip.Id
111+
```
112+
113+
## <a name="CreateGateway"></a>Create the VPN gateway
114+
115+
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.
116+
117+
Create a VPN gateway using the [New-AzVirtualNetworkGateway](/powershell/module/az.network/New-azVirtualNetworkGateway) cmdlet. In this example, we create a route-based Basic SKU VPN gateway. You can create a policy-based gateway instead by specifying `-VpnType "PolicyBased"`.
118+
119+
```azurepowershell-interactive
120+
New-AzVirtualNetworkGateway -Name VNet1GW -ResourceGroupName TestRG1 `
121+
-Location "East US" -IpConfigurations $gwipconfig -GatewayType "Vpn" `
122+
-VpnType "RouteBased" -GatewaySku Basic
123+
```
124+
125+
## <a name="viewgw"></a>View the VPN gateway
126+
127+
You can view the VPN gateway using the [Get-AzVirtualNetworkGateway](/powershell/module/az.network/Get-azVirtualNetworkGateway) cmdlet.
128+
129+
```azurepowershell-interactive
130+
Get-AzVirtualNetworkGateway -Name Vnet1GW -ResourceGroup TestRG1
131+
```
132+
133+
## <a name="viewgwpip"></a>View the public IP addresses
134+
135+
To view the public IP address for your VPN gateway, use the [Get-AzPublicIpAddress](/powershell/module/az.network/Get-azPublicIpAddress) cmdlet. Example:
136+
137+
```azurepowershell-interactive
138+
Get-AzPublicIpAddress -Name VNet1GWpip1 -ResourceGroupName TestRG1
139+
```
140+
141+
## Clean up resources
142+
143+
When you no longer need the resources you created, use the [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup) command to delete the resource group. This deletes the resource group and all of the resources it contains.
144+
145+
```azurepowershell-interactive
146+
Remove-AzResourceGroup -Name TestRG1
147+
```
148+
149+
## Next steps
150+
151+
Once the gateway finishes 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. See the following articles:
152+
153+
* [Create a site-to-site connection](vpn-gateway-create-site-to-site-rm-powershell.md)
154+
* [Create a point-to-site connection](vpn-gateway-howto-point-to-site-rm-ps.md)
155+
* [Create a connection to another virtual network](vpn-gateway-vnet-vnet-rm-ps.md)
39.3 KB
Loading
39.3 KB
Loading

0 commit comments

Comments
 (0)