Skip to content

Commit 6663ff5

Browse files
authored
Merge pull request #4471 from henry416/preview
VPN Client Protocols for gateways
2 parents 5e0b761 + f0f9103 commit 6663ff5

File tree

8 files changed

+777423
-2
lines changed

8 files changed

+777423
-2
lines changed

src/ResourceManager/Network/ChangeLog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
- Updated Add-AzureRMLoadBalancerRuleConfig: Added optional parameter DisableOutboundSNAT
3333
- Updated Set-AzureRMLoadBalancerRuleConfig: Added optional parameter DisableOutboundSNAT
3434

35+
## Version 4.3.2
36+
* New-AzureRmVirtualNetworkGateway: Added IkeV2 P2S support. New optional parameter added
37+
- VpnClientProtocol
38+
* Set-AzureRmVirtualNetworkGateway: Added IkeV2 P2S support. New optional parameter added
39+
- VpnClientProtocol
40+
3541
## Version 4.3.1
3642

3743
## Version 4.3.0

src/ResourceManager/Network/Commands.Network.Test/Commands.Network.Test.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,9 @@
520520
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.VirtualNetworkGatewayConnectionTests\TestVirtualNetworkGatewayConnectionWithActiveAcitveGateway.json">
521521
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
522522
</None>
523+
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.VirtualNetworkGatewayTests\VirtualNetworkGatewayIkeV2Test.json">
524+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
525+
</None>
523526
<None Include="SessionRecords\Commands.Network.Test.ScenarioTests.VirtualNetworkGatewayTests\VirtualNetworkGatewayRouteApiTest.json">
524527
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
525528
</None>

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/VirtualNetworkGatewayTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,12 @@ public void VirtualNetworkGatewayRouteApiTest()
5757
{
5858
NetworkResourcesController.NewInstance.RunPsTest("Test-VirtualNetworkGatewayBgpRouteApi");
5959
}
60+
61+
[Fact]
62+
[Trait(Category.AcceptanceType, Category.CheckIn)]
63+
public void VirtualNetworkGatewayIkeV2Test()
64+
{
65+
NetworkResourcesController.NewInstance.RunPsTest("Test-VirtualNetworkGatewayIkeV2");
66+
}
6067
}
6168
}

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/VirtualNetworkGatewayTests.ps1

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,4 +485,66 @@ function Test-VirtualNetworkGatewayBgpRouteApi
485485
{
486486
Clean-ResourceGroup $rgname
487487
}
488-
}
488+
}
489+
490+
<#
491+
.SYNOPSIS
492+
Virtual network gateway BGP route API test
493+
#>
494+
function Test-VirtualNetworkGatewayIkeV2
495+
{
496+
# Setup
497+
$rgname = Get-ResourceGroupName
498+
$rname = Get-ResourceName
499+
$domainNameLabel = Get-ResourceName
500+
$vnetName = Get-ResourceName
501+
$publicIpName = Get-ResourceName
502+
$vnetGatewayConfigName = Get-ResourceName
503+
$rglocation = Get-ProviderLocation ResourceManagement
504+
$resourceTypeParent = "Microsoft.Network/virtualNetworkGateways"
505+
$location = Get-ProviderLocation $resourceTypeParent
506+
507+
try
508+
{
509+
# Create the resource group
510+
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
511+
512+
# create the client root cert
513+
$clientRootCertName = "BrkLiteTestMSFTRootCA.cer"
514+
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine")]
515+
$samplePublicCertData = "MIIDUzCCAj+gAwIBAgIQRggGmrpGj4pCblTanQRNUjAJBgUrDgMCHQUAMDQxEjAQBgNVBAoTCU1pY3Jvc29mdDEeMBwGA1UEAxMVQnJrIExpdGUgVGVzdCBSb290IENBMB4XDTEzMDExOTAwMjQxOFoXDTIxMDExOTAwMjQxN1owNDESMBAGA1UEChMJTWljcm9zb2Z0MR4wHAYDVQQDExVCcmsgTGl0ZSBUZXN0IFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQC7SmE+iPULK0Rs7mQBO/6a6B6/G9BaMxHgDGzAmSG0Qsyt5e08aqgFnPdkMl3zRJw3lPKGha/JCvHRNrO8UpeAfc4IXWaqxx2iBipHjwmHPHh7+VB8lU0EJcUe7WBAI2n/sgfCwc+xKtuyRVlOhT6qw/nAi8e5don/iHPU6q7GCcnqoqtceQ/pJ8m66cvAnxwJlBFOTninhb2VjtvOfMQ07zPP+ZuYDPxvX5v3nd6yDa98yW4dZPuiGO2s6zJAfOPT2BrtyvLekItnSgAw3U5C0bOb+8XVKaDZQXbGEtOw6NZvD4L2yLd47nGkN2QXloiPLGyetrj3Z2pZYcrZBo8hAgMBAAGjaTBnMGUGA1UdAQReMFyAEOncRAPNcvJDoe4WP/gH2U+hNjA0MRIwEAYDVQQKEwlNaWNyb3NvZnQxHjAcBgNVBAMTFUJyayBMaXRlIFRlc3QgUm9vdCBDQYIQRggGmrpGj4pCblTanQRNUjAJBgUrDgMCHQUAA4IBAQCGyHhMdygS0g2tEUtRT4KFM+qqUY5HBpbIXNAav1a1dmXpHQCziuuxxzu3iq4XwnWUF1OabdDE2cpxNDOWxSsIxfEBf9ifaoz/O1ToJ0K757q2Rm2NWqQ7bNN8ArhvkNWa95S9gk9ZHZLUcjqanf0F8taJCYgzcbUSp+VBe9DcN89sJpYvfiBiAsMVqGPc/fHJgTScK+8QYrTRMubtFmXHbzBSO/KTAP5rBTxse88EGjK5F8wcedvge2Ksk6XjL3sZ19+Oj8KTQ72wihN900p1WQldHrrnbixSpmHBXbHr9U0NQigrJp5NphfuU5j81C8ixvfUdwyLmTv7rNA7GTAD";
516+
$rootCert = New-AzureRmVpnClientRootCertificate -Name $clientRootCertName -PublicCertData $samplePublicCertData
517+
518+
# Create the Virtual Network
519+
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24
520+
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
521+
$vnet = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
522+
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet
523+
524+
# Create the IP config
525+
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
526+
$vnetIpConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet
527+
528+
# Create & Get IkeV2 + SSTP virtualnetworkgateway
529+
New-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -GatewayType Vpn -VpnType RouteBased -EnableBgp $false -GatewaySku VpnGw1 -VpnClientProtocol @( "IkeV2", "SSTP" ) -VpnClientAddressPool 201.169.0.0/16 -VpnClientRootCertificates $rootCert
530+
$actual = Get-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
531+
Assert-AreEqual "VpnGw1" $actual.Sku.Tier
532+
$protocols = $actual.VpnClientConfiguration.VpnClientProtocols
533+
Assert-AreEqual 2 @($protocols).Count
534+
Assert-AreEqual "IkeV2" $protocols[0]
535+
Assert-AreEqual "SSTP" $protocols[1]
536+
Assert-AreEqual "201.169.0.0/16" $actual.VpnClientConfiguration.VpnClientAddressPool.AddressPrefixes
537+
538+
# Update gateway to IkeV2 only
539+
Set-AzureRmVirtualNetworkGateway -VirtualNetworkGateway $actual -VpnClientProtocol IkeV2
540+
$actual = Get-AzureRmVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
541+
$protocols = $actual.VpnClientConfiguration.VpnClientProtocols
542+
Assert-AreEqual 1 @($protocols).Count
543+
Assert-AreEqual "IkeV2" $protocols[0]
544+
}
545+
finally
546+
{
547+
# Cleanup
548+
Clean-ResourceGroup $rgname
549+
}
550+
}

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.VirtualNetworkGatewayTests/VirtualNetworkGatewayIkeV2Test.json

Lines changed: 777307 additions & 0 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network/Models/PSVpnClientConfiguration.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public class PSVpnClientConfiguration
2424

2525
public List<PSVpnClientRootCertificate> VpnClientRootCertificates { get; set; }
2626

27-
27+
public List<string> VpnClientProtocols { get; set; }
28+
2829
[JsonIgnore]
2930
public string VpnClientAddressPoolText
3031
{

src/ResourceManager/Network/Commands.Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd
117117
[ValidateNotNullOrEmpty]
118118
public List<string> VpnClientAddressPool { get; set; }
119119

120+
[Parameter(
121+
Mandatory = false,
122+
ValueFromPipelineByPropertyName = true,
123+
HelpMessage = "The list of P2S VPN client tunneling protocols")]
124+
[ValidateSet(
125+
MNM.VpnClientProtocol.SSTP,
126+
MNM.VpnClientProtocol.IkeV2)]
127+
[ValidateNotNullOrEmpty]
128+
public List<string> VpnClientProtocol { get; set; }
129+
120130
[Parameter(
121131
Mandatory = false,
122132
ValueFromPipelineByPropertyName = true,
@@ -281,6 +291,16 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway()
281291
vnetGateway.VpnClientConfiguration.VpnClientAddressPool.AddressPrefixes = this.VpnClientAddressPool;
282292
}
283293

294+
if (this.VpnClientProtocol != null)
295+
{
296+
vnetGateway.VpnClientConfiguration.VpnClientProtocols = this.VpnClientProtocol;
297+
}
298+
else
299+
{
300+
// set default
301+
vnetGateway.VpnClientConfiguration.VpnClientProtocols = new List<string> { MNM.VpnClientProtocol.SSTP, MNM.VpnClientProtocol.IkeV2 };
302+
}
303+
284304
if (this.VpnClientRootCertificates != null)
285305
{
286306
vnetGateway.VpnClientConfiguration.VpnClientRootCertificates = this.VpnClientRootCertificates;

src/ResourceManager/Network/Commands.Network/VirtualNetworkGateway/UpdateAzureVirtualNetworkGatewayCommand.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@ public class SetAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd
6060
[ValidateNotNullOrEmpty]
6161
public List<string> VpnClientAddressPool { get; set; }
6262

63+
[Parameter(
64+
Mandatory = false,
65+
ValueFromPipelineByPropertyName = true,
66+
HelpMessage = "A list of P2S VPN client tunneling protocols")]
67+
[ValidateSet(
68+
MNM.VpnClientProtocol.SSTP,
69+
MNM.VpnClientProtocol.IkeV2)]
70+
[ValidateNotNullOrEmpty]
71+
public List<string> VpnClientProtocol { get; set; }
72+
6373
[Parameter(
6474
Mandatory = false,
6575
ValueFromPipelineByPropertyName = true,
@@ -158,6 +168,11 @@ public override void Execute()
158168
this.VirtualNetworkGateway.VpnClientConfiguration.VpnClientAddressPool.AddressPrefixes = this.VpnClientAddressPool;
159169
}
160170

171+
if (this.VpnClientProtocol != null)
172+
{
173+
this.VirtualNetworkGateway.VpnClientConfiguration.VpnClientProtocols = this.VpnClientProtocol;
174+
}
175+
161176
if (this.VpnClientRootCertificates != null)
162177
{
163178
this.VirtualNetworkGateway.VpnClientConfiguration.VpnClientRootCertificates = this.VpnClientRootCertificates;

0 commit comments

Comments
 (0)