Skip to content

Commit 6e4f315

Browse files
dtuCloudDan Tu
andauthored
Add DisableTcpStateTracking to Nic Property (#19486)
* draft * add tests * 2nd try * trial * add in generated.format Co-authored-by: Dan Tu <[email protected]>
1 parent 1f5709c commit 6e4f315

File tree

9 files changed

+2099
-0
lines changed

9 files changed

+2099
-0
lines changed

src/Network/Network.Test/ScenarioTests/NetworkInterfaceTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@ public void TestNetworkInterfaceWithAcceleratedNetworking()
115115
TestRunner.RunTestScript("Test-NetworkInterfaceWithAcceleratedNetworking");
116116
}
117117

118+
[Fact]
119+
[Trait(Category.AcceptanceType, Category.CheckIn)]
120+
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]
121+
public void TestNetworkInterfaceWithDisableTcpStateTracking()
122+
{
123+
TestRunner.RunTestScript("Test-NetworkInterfaceWithDisableTcpStateTracking");
124+
}
125+
118126
[Fact]
119127
[Trait(Category.AcceptanceType, Category.CheckIn)]
120128
[Trait(Category.Owner, NrpTeamAlias.sdnnrp)]

src/Network/Network.Test/ScenarioTests/NetworkInterfaceTests.ps1

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,56 @@ function Test-NetworkInterfaceWithAcceleratedNetworking
983983
}
984984
}
985985

986+
<#
987+
.SYNOPSIS
988+
Tests creating new simple public networkinterface with disableTcpStateTracking Property.
989+
#>
990+
function Test-NetworkInterfaceWithDisableTcpStateTracking
991+
{
992+
# Setup
993+
$rgname = Get-ResourceGroupName
994+
$vnetName = Get-ResourceName
995+
$subnetName = Get-ResourceName
996+
$publicIpName = Get-ResourceName
997+
$nicName = Get-ResourceName
998+
$domainNameLabel = Get-ResourceName
999+
$rglocation = Get-ProviderLocation ResourceManagement "eastus2euap"
1000+
$resourceTypeParent = "Microsoft.Network/networkInterfaces"
1001+
$location = Get-ProviderLocation $resourceTypeParent "eastus2euap"
1002+
1003+
try
1004+
{
1005+
# Create the resource group
1006+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }
1007+
# Create the Virtual Network
1008+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.1.0/24
1009+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
1010+
1011+
# Create the publicip
1012+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic -DomainNameLabel $domainNameLabel
1013+
1014+
# Create NetworkInterface with DisableTcpStateTracking Property set to true
1015+
$actualNic = New-AzNetworkInterface -Name $nicName -ResourceGroupName $rgname -Location $location -Subnet $vnet.Subnets[0] -PublicIpAddress $publicip -DisableTcpStateTracking true
1016+
$expectedNic = Get-AzNetworkInterface -Name $nicName -ResourceGroupName $rgname
1017+
1018+
Assert-NotNull $expectedNic.ResourceGuid
1019+
Assert-AreEqual "Succeeded" $expectedNic.ProvisioningState
1020+
Assert-AreEqual $true $expectedNic.DisableTcpStateTracking
1021+
1022+
# Delete ResourceGroup
1023+
$delete = Remove-AzNetworkInterface -ResourceGroupName $rgname -name $nicName -PassThru -Force
1024+
Assert-AreEqual true $delete
1025+
1026+
$list = Get-AzNetworkInterface -ResourceGroupName $rgname
1027+
Assert-AreEqual 0 @($list).Count
1028+
}
1029+
finally
1030+
{
1031+
# Cleanup
1032+
Clean-ResourceGroup $rgname
1033+
}
1034+
}
1035+
9861036
<#
9871037
.SYNOPSIS
9881038
Test creating new NetworkInterfaceTapConfiguration using minimal set of parameters

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.NetworkInterfaceTests/TestNetworkInterfaceWithDisableTcpStateTracking.json

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

src/Network/Network/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
- `New-AzVirtualNetworkGatewayConnection`
2626
* Updated commandlet to support no-internet advertise CustomIpPrefix.
2727
- `Update-AzCustomIpPrefix`
28+
* Updated commandlet to support create/update nic with DisableTcpStateTracking property
29+
- `New-AzNetworkInterface`
2830
* Updated commandlets to support specifying a VirtualRouterAsn on Virtual Hub
2931
- `NewAzureRmVirtualHubCommand.cs`
3032
- `UpdateAzureRmVirtualHubCommand.cs`

src/Network/Network/Models/PSNetworkInterface.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ public class PSNetworkInterface : PSTopLevelResource, INetworkInterfaceReference
4343
[Ps1Xml(Target = ViewControl.Table)]
4444
public bool? EnableIPForwarding { get; set; }
4545

46+
[Ps1Xml(Target = ViewControl.Table)]
47+
public string DisableTcpStateTracking { get; set; }
48+
4649
public List<string> HostedWorkloads { get; set; }
4750

4851
public PSNetworkSecurityGroup NetworkSecurityGroup { get; set; }

src/Network/Network/Network.format.ps1xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,6 +1876,10 @@
18761876
<Label>VnetEncryptionSupported</Label>
18771877
<PropertyName>VnetEncryptionSupported</PropertyName>
18781878
</ListItem>
1879+
<ListItem>
1880+
<Label>DisableTcpStateTracking</Label>
1881+
<PropertyName>DisableTcpStateTracking</PropertyName>
1882+
</ListItem>
18791883
<ListItem>
18801884
<Label>AuxiliaryMode</Label>
18811885
<PropertyName>AuxiliaryMode</PropertyName>

src/Network/Network/Network.generated.format.ps1xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2008,6 +2008,10 @@
20082008
<Alignment>Left</Alignment>
20092009
<Label>EnableAcceleratedNetworking</Label>
20102010
</TableColumnHeader>
2011+
<TableColumnHeader>
2012+
<Alignment>Left</Alignment>
2013+
<Label>DisableTcpStateTracking</Label>
2014+
</TableColumnHeader>
20112015
<TableColumnHeader>
20122016
<Alignment>Left</Alignment>
20132017
<Label>EnableIPForwarding</Label>
@@ -2043,6 +2047,10 @@
20432047
<TableColumnItem>
20442048
<Alignment>Left</Alignment>
20452049
<PropertyName>EnableAcceleratedNetworking</PropertyName>
2050+
</TableColumnItem>
2051+
<TableColumnItem>
2052+
<Alignment>Left</Alignment>
2053+
<PropertyName>DisableTcpStateTracking</PropertyName>
20462054
</TableColumnItem>
20472055
<TableColumnItem>
20482056
<Alignment>Left</Alignment>

src/Network/Network/NetworkInterface/NewAzureNetworkInterfaceCommand.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,12 @@ public class NewAzureNetworkInterfaceCommand : NetworkInterfaceBaseCmdlet
223223
HelpMessage = "The Internal Dns name")]
224224
public string InternalDnsNameLabel { get; set; }
225225

226+
[Parameter(
227+
Mandatory = false,
228+
ValueFromPipelineByPropertyName = true,
229+
HelpMessage = "DisableTcpStateTracking")]
230+
public string DisableTcpStateTracking { get; set; }
231+
226232
[Parameter(
227233
Mandatory = false,
228234
HelpMessage = "EnableIPForwarding")]
@@ -290,6 +296,11 @@ private PSNetworkInterface CreateNetworkInterface()
290296
networkInterface.ExtendedLocation = new PSExtendedLocation(this.EdgeZone);
291297
}
292298

299+
if (!string.IsNullOrEmpty(DisableTcpStateTracking))
300+
{
301+
networkInterface.DisableTcpStateTracking = this.DisableTcpStateTracking;
302+
}
303+
293304
networkInterface.EnableIPForwarding = this.EnableIPForwarding.IsPresent;
294305
networkInterface.EnableAcceleratedNetworking = this.EnableAcceleratedNetworking.IsPresent;
295306

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,20 @@ Accept pipeline input: False
186186
Accept wildcard characters: False
187187
```
188188
189+
### -DisableTcpStateTracking
190+
Indicates whether to disable tcp state tracking.
191+
192+
```yaml
193+
Type: System.String
194+
Parameter Sets: (All)
195+
Aliases:
196+
Required: False
197+
Position: Named
198+
Default value: None
199+
Accept pipeline input: True (ByPropertyName)
200+
Accept wildcard characters: False
201+
```
202+
189203
### -DnsServer
190204
Specifies the DNS server for the network interface.
191205

0 commit comments

Comments
 (0)