How to create Basic Azure VPN Gateway

arslakwij200 20 Reputation points


I'm trying to create a Basic SKU of a VPN gateway. I know that it needs to be created from the CLI and not from the web portal so I tried to do it but so far have failed. I have created a VPN tunnel using VpnGW1 but it's too expensive for us so I deleted the gateway. All other resources required for the VPN are already there. Any help would be greatly appreciated. Thanks.

Azure VPN Gateway
Azure VPN Gateway
An Azure service that enables the connection of on-premises networks to Azure through site-to-site virtual private networks.
1,361 questions
A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.
919 questions
0 comments No comments
{count} votes

Accepted answer
  1. TP 74,236 Reputation points


    Please see sample code below. You can copy/paste it into PowerShell Azure Cloud Shell:

    $location = "westus3"
    $resourceGroup = "basic-vnet-gateway-group"
    $vnetAddressSpace = ""
    $gatewaySubnet = ""
    New-AzResourceGroup -Name $resourceGroup -Location $location
    $subnetConfig = New-AzVirtualNetworkSubnetConfig -Name GatewaySubnet -AddressPrefix $gatewaySubnet
    $vngwPIP = New-AzPublicIpAddress -Name myvngw-ip -ResourceGroupName $resourceGroup -Location $location -Sku Basic -AllocationMethod Dynamic
    $vnet = New-AzVirtualNetwork -Name myvngw-vnet -ResourceGroupName $resourceGroup -Location $location -AddressPrefix $vnetAddressSpace -Subnet $subnetConfig
    $subnet = Get-AzVirtualNetworkSubnetConfig -Name GatewaySubnet -VirtualNetwork $vnet
    $vngwIpConfig = New-AzVirtualNetworkGatewayIpConfig -Name vngwipconfig -SubnetId $subnet.Id -PublicIpAddressId $vngwPIP.Id
    New-AzVirtualNetworkGateway -Name myvngw-gw -ResourceGroupName $resourceGroup -Location $location -IpConfigurations $vngwIpConfig -GatewayType Vpn -VpnType RouteBased -GatewaySku Basic

    Please click Accept Answer and upvote if above was helpful.



0 additional answers

Sort by: Most helpful