Deploy and Configure Azure VPN Gateway

This document guides you through the process of deploying and configuring an Azure VPN Gateway to establish secure, cross-premises connectivity between your on-premises networks and your Azure virtual networks.

Tip: For optimal performance and reliability, plan your VPN gateway configuration carefully, considering factors like throughput, connection types, and region.

Prerequisites

Deployment Steps

1. Create a VPN Gateway

You can deploy a VPN gateway using the Azure portal, Azure CLI, or Azure PowerShell.

Using Azure Portal

  1. Navigate to the Azure portal.
  2. Search for "Virtual network gateways" and select it.
  3. Click + Create.
  4. Configure the following settings:
    • Subscription: Select your Azure subscription.
    • Resource group: Choose an existing or create a new resource group.
    • Name: Provide a unique name for your VPN gateway.
    • Region: Select the same region as your VNet.
    • Gateway type: Choose VPN.
    • VPN type: Select the type that matches your on-premises device (e.g., RouteBased for most scenarios).
    • SKU: Choose a SKU that meets your performance and feature requirements (e.g., VpnGw1, VpnGw2AZ).
    • Generation: Select the generation (e.g., Generation1, Generation2).
    • Virtual network: Select the VNet that contains your GatewaySubnet.
    • Public IP address: Create a new Standard SKU, Static IP address or select an existing one.
    • Enable active-active mode: (Optional) For higher availability.
    • Configure BGP: (Optional) If you plan to use BGP for dynamic routing.
  5. Click Review + create, then Create.

Using Azure CLI

The following is a simplified example. Refer to the official Azure CLI documentation for detailed parameters.


az network vnet-gateway create \
  --name MyVpnGateway \
  --resource-group MyResourceGroup \
  --location eastus \
  --gateway-type Vpn \
  --vpn-type RouteBased \
  --sku VpnGw1 \
  --vnet <YOUR_VNET_NAME> \
  --public-ip-address <YOUR_PUBLIC_IP_NAME>
            
Note: VPN gateway deployment can take 30-45 minutes.

2. Create a Local Network Gateway

A local network gateway represents your on-premises network. It contains the public IP address of your on-premises VPN device and the address spaces of your on-premises network.

  1. In the Azure portal, search for "Local network gateways" and select it.
  2. Click + Create.
  3. Configure the following settings:
    • Resource group: Same as your VPN gateway.
    • Region: Same as your VPN gateway.
    • Name: A descriptive name for your on-premises network (e.g., OnPremisesNetwork).
    • IP address: The public IP address of your on-premises VPN device.
    • Address spaces: The IP address ranges of your on-premises network(s).
    • Configure BGP settings: (Optional) If applicable.
  4. Click Review + create, then Create.

3. Create a Connection

This step links your Azure VPN Gateway to your Local Network Gateway, establishing the VPN tunnel.

  1. Navigate to your created Azure VPN Gateway resource.
  2. Under Settings, select Connections.
  3. Click + Add.
  4. Configure the following settings:
    • Name: A name for the connection (e.g., VNetToOnPrem).
    • Connection type: Select Site-to-site (IPsec).
    • Virtual network gateway: Automatically selected.
    • Local network gateway: Select the local network gateway you created.
    • Shared key (PSK): Enter a strong pre-shared key. This key must match on both the Azure side and your on-premises VPN device.
    • IKE protocol: Choose the appropriate IKE protocol (IKEv2 is recommended).
    • Enable BGP: (Optional) If BGP is configured.
  5. Click OK.
Important: Ensure the pre-shared key (PSK) is identical on the Azure connection and your on-premises VPN device configuration.

On-Premises Device Configuration

Configure your on-premises VPN device to establish a tunnel to your Azure VPN Gateway. This typically involves:

Consult your VPN device vendor's documentation for specific configuration steps.

Verification

After both Azure and your on-premises device are configured, the connection status in the Azure portal should change to Connected.

Test connectivity by pinging resources across the tunnel or accessing services.