Skip to content

Commit c5385ee

Browse files
misbamustaqimmisbamominwyunchi-ms
authored
Adding DisableIPsecProtection check(bool) to Virtual Network Gateway (Azure#18029)
* Adding DisableIPsecProtection to VirtualNetworkGateway * adding session records * updated help document * Update changelog Co-authored-by: Misba Momin <[email protected]> Co-authored-by: Yunchi Wang <[email protected]>
1 parent 224effc commit c5385ee

File tree

8 files changed

+4947
-1001
lines changed

8 files changed

+4947
-1001
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ public void TestSetVirtualNetworkGatewayCRUD()
5959
TestRunner.RunTestScript("Test-SetVirtualNetworkGatewayCRUD");
6060
}
6161

62+
[Fact]
63+
[Trait(Category.AcceptanceType, Category.CheckIn)]
64+
[Trait(Category.Owner, NrpTeamAlias.brooklynft_subset2)]
65+
public void VirtualNetworkGatewayDisableIPsecProtection()
66+
{
67+
TestRunner.RunTestScript("Test-VirtualNetworkGatewayDisableIPsecProtection");
68+
}
69+
6270
[Fact(Skip = "Skipped due to intermittent backend failures")]
6371
[Trait(Category.AcceptanceType, Category.CheckIn)]
6472
[Trait(Category.Owner, NrpTeamAlias.brooklynft_subset2)]

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

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ function Test-VirtualNetworkGatewayCRUD
115115
$ipconfigurationId = $vnetIpConfig.id
116116
$addresslist = @('169.254.21.25')
117117
$gw1ipconfBgp = New-AzIpConfigurationBgpPeeringAddressObject -IpConfigurationId $ipconfigurationId -CustomAddress $addresslist
118-
$job = New-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -IpConfigurationBgpPeeringAddresses $gw1ipconfBgp -GatewayType Vpn -VpnType RouteBased -EnableBgp $false -AsJob
118+
$job = New-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -IpConfigurationBgpPeeringAddresses $gw1ipconfBgp -GatewayType Vpn -VpnType RouteBased -EnableBgp $false -DisableIPsecProtection $false -AsJob
119119
$job | Wait-Job
120120
$actual = $job | Receive-Job
121121
$expected = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
@@ -124,6 +124,7 @@ function Test-VirtualNetworkGatewayCRUD
124124
Assert-AreEqual "Vpn" $expected.GatewayType
125125
Assert-AreEqual "RouteBased" $expected.VpnType
126126
Assert-AreEqual 1 @($expected.BgpSettings.BGPPeeringAddresses).Count
127+
Assert-AreEqual $expected.DisableIPsecProtection $actual.DisableIPsecProtection
127128

128129
# List virtualNetworkGateways
129130
$list = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname
@@ -161,6 +162,64 @@ function Test-VirtualNetworkGatewayCRUD
161162
}
162163
}
163164

165+
<#
166+
.SYNOPSIS
167+
Virtual network gateway tests
168+
#>
169+
function Test-VirtualNetworkGatewayDisableIPsecProtection
170+
{
171+
# Setup
172+
$rgname = Get-ResourceGroupName
173+
$rname = Get-ResourceName
174+
$domainNameLabel = Get-ResourceName
175+
$vnetName = Get-ResourceName
176+
$publicIpName = Get-ResourceName
177+
$vnetGatewayConfigName = Get-ResourceName
178+
$rglocation = Get-ProviderLocation ResourceManagement
179+
$resourceTypeParent = "Microsoft.Network/virtualNetworkGateways"
180+
$location = Get-ProviderLocation $resourceTypeParent
181+
182+
try
183+
{
184+
# Create the resource group
185+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
186+
187+
# Create the Virtual Network
188+
$subnet = New-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24
189+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
190+
$vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname
191+
$subnet = Get-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet
192+
193+
# Create the publicip
194+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
195+
196+
# Create & Get virtualnetworkgateway
197+
$vnetIpConfig = New-AzVirtualNetworkGatewayIpConfig -Name $vnetGatewayConfigName -PublicIpAddress $publicip -Subnet $subnet
198+
$ipconfigurationId = $vnetIpConfig.id
199+
$addresslist = @('169.254.21.25')
200+
$gw1ipconfBgp = New-AzIpConfigurationBgpPeeringAddressObject -IpConfigurationId $ipconfigurationId -CustomAddress $addresslist
201+
$job = New-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -IpConfigurations $vnetIpConfig -IpConfigurationBgpPeeringAddresses $gw1ipconfBgp -GatewayType Vpn -VpnType RouteBased -EnableBgp $false -DisableIPsecProtection $true -AsJob
202+
$job | Wait-Job
203+
$actual = $job | Receive-Job
204+
$expected = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname
205+
Assert-AreEqual $expected.DisableIPsecProtection $actual.DisableIPsecProtection
206+
207+
# Delete virtualNetworkGateway
208+
$job = Remove-AzVirtualNetworkGateway -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force -AsJob
209+
$job | Wait-Job
210+
$delete = $job | Receive-Job
211+
Assert-AreEqual true $delete
212+
213+
$list = Get-AzVirtualNetworkGateway -ResourceGroupName $actual.ResourceGroupName
214+
Assert-AreEqual 0 @($list).Count
215+
}
216+
finally
217+
{
218+
# Cleanup
219+
Clean-ResourceGroup $rgname
220+
}
221+
}
222+
164223
<#
165224
.SYNOPSIS
166225
Virtual network gateway tests

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.VirtualNetworkGatewayTests/TestVirtualNetworkGatewayCRUD.json

Lines changed: 1298 additions & 999 deletions
Large diffs are not rendered by default.

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.VirtualNetworkGatewayTests/VirtualNetworkGatewayDisableIPsecProtection.json

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

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
--->
2020

2121
## Upcoming Release
22+
* Added `DisableIPsecProtection` to `Virtual Network Gateway`.
2223
* Added new cmdlets to create/manage authorization objects for ExpressRoutePort:
2324
- `Add-AzExpressRoutePortAuthorization`
2425
- `Get-AzExpressRoutePortAuthorization`

src/Network/Network/Models/PSVirtualNetworkGateway.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ public class PSVirtualNetworkGateway : PSTopLevelResource
3131
[Ps1Xml(Target = ViewControl.Table)]
3232
public bool EnableBgp { get; set; }
3333

34+
[Ps1Xml(Target = ViewControl.Table)]
35+
public bool DisableIPsecProtection { get; set; }
36+
3437
[Ps1Xml(Target = ViewControl.Table)]
3538
public bool EnablePrivateIpAddress { get; set; }
3639

src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd
9292
HelpMessage = "EnableBgp Flag")]
9393
public bool EnableBgp { get; set; }
9494

95+
[Parameter(
96+
Mandatory = false,
97+
ValueFromPipelineByPropertyName = true,
98+
HelpMessage = "Disable IPsec Protection Flag")]
99+
public bool DisableIPsecProtection { get; set; }
100+
95101
[Parameter(
96102
Mandatory = false,
97103
HelpMessage = "Flag to enable Active Active feature on virtual network gateway")]
@@ -360,6 +366,7 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway()
360366
vnetGateway.GatewayType = this.GatewayType;
361367
vnetGateway.VpnType = this.VpnType;
362368
vnetGateway.EnableBgp = this.EnableBgp;
369+
vnetGateway.DisableIPsecProtection = this.DisableIPsecProtection;
363370
vnetGateway.ActiveActive = this.EnableActiveActiveFeature.IsPresent;
364371
vnetGateway.EnablePrivateIpAddress = this.EnablePrivateIpAddress.IsPresent;
365372

src/Network/Network/help/New-AzVirtualNetworkGateway.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Creates a Virtual Network Gateway
1616
```
1717
New-AzVirtualNetworkGateway -Name <String> -ResourceGroupName <String> -Location <String>
1818
[-IpConfigurations <PSVirtualNetworkGatewayIpConfiguration[]>] [-GatewayType <String>] [-VpnType <String>]
19-
[-EnableBgp <Boolean>] [-EnableActiveActiveFeature] [-EnablePrivateIpAddress] [-GatewaySku <String>]
19+
[-EnableBgp <Boolean>] [-DisableIPsecProtection <Boolean>] [-EnableActiveActiveFeature] [-EnablePrivateIpAddress] [-GatewaySku <String>]
2020
[-GatewayDefaultSite <PSLocalNetworkGateway>] [-VpnClientAddressPool <String[]>]
2121
[-VpnClientProtocol <String[]>] [-VpnAuthenticationType <String[]>]
2222
[-VpnClientRootCertificates <PSVpnClientRootCertificate[]>]
@@ -319,6 +319,21 @@ Accept pipeline input: True (ByPropertyName)
319319
Accept wildcard characters: False
320320
```
321321
322+
### -DisableIPsecProtection
323+
The Flag disables IPsec Protection on VirtualNetworkGateway.
324+
325+
```yaml
326+
Type: System.Boolean
327+
Parameter Sets: (All)
328+
Aliases:
329+
330+
Required: False
331+
Position: Named
332+
Default value: False
333+
Accept pipeline input: True (ByPropertyName)
334+
Accept wildcard characters: False
335+
```
336+
322337
### -EnableBgpRouteTranslationForNat
323338
Flag to enable BgpRouteTranslationForNat on this VirtualNetworkGateway.
324339

0 commit comments

Comments
 (0)