Skip to content

Commit 14ba012

Browse files
authored
Merge pull request #146704 from cherylmc/scp2s
update
2 parents 29b3fc7 + 9fefb0d commit 14ba012

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

articles/vpn-gateway/scripts/vpn-gateway-sample-point-to-site-certificate-authentication-powershell.md

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,66 @@
11
---
2-
title: 'Azure PowerShell script sample - Configure point-to-site VPN with native Azure certificate authentication | Microsoft Docs'
2+
title: 'Azure PowerShell script sample - Configure a P2S VPN - certificate authentication'
3+
titleSuffix: Azure VPN Gateway
34
description: Configure point-to-site VPN with native Azure certificate authentication using self-signed certificates. This article uses PowerShell.
45
services: vpn-gateway
5-
documentationcenter: vpn-gateway
6-
author: kumudD
6+
author: cherylmc
77

88
ms.service: vpn-gateway
9-
ms.devlang: powershell
109
ms.topic: sample
11-
ms.date: 01/10/2020
10+
ms.date: 02/11/2021
1211
ms.author: alzam
1312

1413
---
1514

16-
# Configure a point-to-site VPN using native Azure certificate authentication
15+
# Configure a point-to-site VPN - certificate authentication - PowerShell script sample
1716

18-
This script creates a route-based VPN Gateway and adds point-to-site configuration using native Azure certificate authentication
17+
This script creates a route-based VPN gateway and adds point-to-site configuration using native Azure certificate authentication.
1918

2019
[!INCLUDE [updated-for-az](../../../includes/updated-for-az.md)]
2120

2221
```azurepowershell-interactive
2322
# Declare variables
2423
$VNetName = "VNet1"
24+
$RG = "TestRG1"
25+
$Location = "East US"
2526
$FESubName = "FrontEnd"
26-
$BESubName = "Backend"
27-
$GWSubName = "GatewaySubnet"
28-
$VNetPrefix1 = "10.0.0.0/16"
27+
$VNetPrefix1 = "10.1.0.0/16"
2928
$FESubPrefix = "10.1.0.0/24"
30-
$BESubPrefix = "10.1.1.0/24"
3129
$GWSubPrefix = "10.1.255.0/27"
3230
$VPNClientAddressPool = "192.168.0.0/24"
33-
$RG = "TestRG1"
34-
$Location = "East US"
3531
$GWName = "VNet1GW"
3632
$GWIPName = "VNet1GWIP"
37-
$GWIPconfName = "gwipconf"
33+
3834
# Create a resource group
39-
New-AzResourceGroup -Name TestRG1 -Location EastUS
35+
New-AzResourceGroup -Name $RG -Location EastUS
4036
# Create a virtual network
4137
$virtualNetwork = New-AzVirtualNetwork `
42-
-ResourceGroupName TestRG1 `
38+
-ResourceGroupName $RG `
4339
-Location EastUS `
44-
-Name VNet1 `
45-
-AddressPrefix 10.1.0.0/16
40+
-Name $VNetName `
41+
-AddressPrefix $VNetPrefix1
4642
# Create a subnet configuration
4743
$subnetConfig = Add-AzVirtualNetworkSubnetConfig `
48-
-Name Frontend `
49-
-AddressPrefix 10.1.0.0/24 `
44+
-Name $FESubName `
45+
-AddressPrefix $FESubPrefix `
5046
-VirtualNetwork $virtualNetwork
5147
# Set the subnet configuration for the virtual network
5248
$virtualNetwork | Set-AzVirtualNetwork
5349
# Add a gateway subnet
54-
$vnet = Get-AzVirtualNetwork -ResourceGroupName TestRG1 -Name VNet1
55-
Add-AzVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix 10.1.255.0/27 -VirtualNetwork $vnet
50+
$vnet = Get-AzVirtualNetwork -ResourceGroupName $RG -Name $VNetName
51+
Add-AzVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GWSubPrefix -VirtualNetwork $vnet
5652
# Set the subnet configuration for the virtual network
5753
$vnet | Set-AzVirtualNetwork
5854
# Request a public IP address
59-
$gwpip= New-AzPublicIpAddress -Name VNet1GWIP -ResourceGroupName TestRG1 -Location 'East US' `
55+
$gwpip= New-AzPublicIpAddress -Name $GWIPName -ResourceGroupName $RG -Location $Location `
6056
-AllocationMethod Dynamic
6157
# Create the gateway IP address configuration
62-
$vnet = Get-AzVirtualNetwork -Name VNet1 -ResourceGroupName TestRG1
58+
$vnet = Get-AzVirtualNetwork -Name $VNetName -ResourceGroupName $RG
6359
$subnet = Get-AzVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $vnet
6460
$gwipconfig = New-AzVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $subnet.Id -PublicIpAddressId $gwpip.Id
6561
# Create the VPN gateway
66-
New-AzVirtualNetworkGateway -Name VNet1GW -ResourceGroupName TestRG1 `
67-
-Location 'East US' -IpConfigurations $gwipconfig -GatewayType Vpn `
62+
New-AzVirtualNetworkGateway -Name $GWName -ResourceGroupName $RG `
63+
-Location $Location -IpConfigurations $gwipconfig -GatewayType Vpn `
6864
-VpnType RouteBased -GatewaySku VpnGw1 -VpnClientProtocol "IKEv2"
6965
# Add the VPN client address pool
7066
$Gateway = Get-AzVirtualNetworkGateway -ResourceGroupName $RG -Name $GWName
@@ -82,8 +78,8 @@ $cert = new-object System.Security.Cryptography.X509Certificates.X509Certificate
8278
$CertBase64 = [system.convert]::ToBase64String($cert.RawData)
8379
$p2srootcert = New-AzVpnClientRootCertificate -Name $P2SRootCertName -PublicCertData $CertBase64
8480
Add-AzVpnClientRootCertificate -VpnClientRootCertificateName $P2SRootCertName `
85-
-VirtualNetworkGatewayname "VNet1GW" `
86-
-ResourceGroupName "TestRG1" -PublicCertData $CertBase64
81+
-VirtualNetworkGatewayname $GWName `
82+
-ResourceGroupName $RG -PublicCertData $CertBase64
8783
8884
```
8985

@@ -103,16 +99,16 @@ This script uses the following commands to create the deployment. Each item in t
10399
|---|---|
104100
| [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig) | Adds a subnet configuration. This configuration is used with the virtual network creation process. |
105101
| [Add-AzVpnClientRootCertificate](/powershell/module/az.network/add-azvpnclientrootcertificate) | Uploads the root certificate public key information to the VPN gateway.|
106-
| [Get-AzVirtualNetwork](/powershell/module/az.network/get-azvirtualnetwork) | Gets a virtual network details. |
107-
| [Get-AzVirtualNetworkGateway](/powershell/module/az.network/get-azvirtualnetworkgateway) | Gets a virtual network gateway details. |
102+
| [Get-AzVirtualNetwork](/powershell/module/az.network/get-azvirtualnetwork) | Gets virtual network details. |
103+
| [Get-AzVirtualNetworkGateway](/powershell/module/az.network/get-azvirtualnetworkgateway) | Gets virtual network gateway details. |
108104
| [Get-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/get-azvirtualnetworksubnetconfig) | Gets the virtual network subnet configuration details. |
109105
| [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup) | Creates a resource group in which all resources are stored. |
110106
| [New-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/new-azvirtualnetworksubnetconfig) | Creates a subnet configuration. This configuration is used with the virtual network creation process. |
111107
| [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork) | Creates a virtual network. |
112108
| [New-AzPublicIpAddress](/powershell/module/az.network/new-azpublicipaddress) | Creates a public IP address. |
113109
| [New-AzVirtualNetworkGatewayIpConfig](/powershell/module/az.network/new-azvirtualnetworkgatewayipconfig) | Creates a new gateway ip configuration. |
114110
| [New-AzVirtualNetworkGateway](/powershell/module/az.network/new-azvirtualnetworkgateway) | Creates a VPN gateway. |
115-
| [New-SelfSignedCertificate](/powershell/module/pkiclient/new-selfsignedcertificate?view=win10-ps) | Creates a new self-signed root certificate. |
111+
| [New-SelfSignedCertificate](/powershell/module/pkiclient/new-selfsignedcertificate) | Creates a new self-signed root certificate. |
116112
| [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup) | Removes a resource group and all resources contained within. |
117113
| [Set-AzVirtualNetwork](/powershell/module/az.network/set-azvirtualnetwork) | Sets the subnet configuration for the virtual network. |
118114

0 commit comments

Comments
 (0)