diff --git a/src/Network/Network.Test/Network.Test.csproj b/src/Network/Network.Test/Network.Test.csproj index 7ca2debed478..28c93c167298 100644 --- a/src/Network/Network.Test/Network.Test.csproj +++ b/src/Network/Network.Test/Network.Test.csproj @@ -14,7 +14,7 @@ - + diff --git a/src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.cs b/src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.cs index 4b2073d1f937..5bccd770f5f9 100644 --- a/src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.cs +++ b/src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.cs @@ -145,5 +145,13 @@ public void TestVirtualNetworkSubnetServiceEndpointPolicies() { TestRunner.RunTestScript("Test-VirtualNetworkSubnetServiceEndpointPolicies"); } + + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.Owner, NrpTeamAlias.sdnnrp)] + public void TestVirtualNetworkCRUDFlowTimeout() + { + TestRunner.RunTestScript("Test-VirtualNetworkCRUD-FlowTimeout"); + } } } diff --git a/src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.ps1 b/src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.ps1 index 1fe6296e7f85..f419175eeaa3 100644 --- a/src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.ps1 +++ b/src/Network/Network.Test/ScenarioTests/VirtualNetworkTests.ps1 @@ -1292,3 +1292,56 @@ function Test-VirtualNetworkSubnetServiceEndpointPolicies Clean-ResourceGroup $rgname } } + +<# +.SYNOPSIS +Tests creating new virtual network with flow timeout. +#> +function Test-VirtualNetworkCRUD-FlowTimeout +{ + # Setup + $rgname = Get-ResourceGroupName + $rname = Get-ResourceName + $rglocation = Get-ProviderLocation ResourceManagement + $resourceTypeParent = "Microsoft.Network/virtualNetworks" + $location = Get-ProviderLocation $resourceTypeParent + + try + { + # Create the resource group + $resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" } + + # Create virtual network + $actual = New-AzVirtualNetwork -ResourceGroupName $rgname -name $rname -location $location -FlowTimeoutInMinutes 15 -AddressPrefix 10.0.0.0/16 + $expected = Get-AzVirtualNetwork -ResourceGroupName $rgname -name $rname + Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName + Assert-AreEqual $expected.Name $actual.Name + Assert-AreEqual $expected.Location $actual.Location + Assert-NotNull $expected.ResourceGuid + Assert-AreEqual "Succeeded" $expected.ProvisioningState + Assert-AreEqual 15 $expected.FlowTimeoutInMinutes + + # Set virtual network + $actual.FlowTimeoutInMinutes = 30 + $actual = Set-AzVirtualNetwork -VirtualNetwork $actual + $expected = Get-AzVirtualNetwork -ResourceGroupName $rgname -name $rname + Assert-AreEqual 30 $expected.FlowTimeoutInMinutes + + # delete + $job = Remove-AzVirtualNetwork -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force -AsJob + $job | Wait-Job + $delete = $job | Receive-Job + Assert-AreEqual true $delete + + $list = Get-AzVirtualNetwork -ResourceGroupName $actual.ResourceGroupName + Assert-AreEqual 0 @($list).Count + + # test error handling + Assert-ThrowsContains { Set-AzVirtualNetwork -VirtualNetwork $actual } "not found"; + } + finally + { + # Cleanup + Clean-ResourceGroup $rgname + } +} \ No newline at end of file diff --git a/src/Network/Network/Models/PSVirtualNetwork.cs b/src/Network/Network/Models/PSVirtualNetwork.cs index 05180bc882b9..4a5370d719f2 100644 --- a/src/Network/Network/Models/PSVirtualNetwork.cs +++ b/src/Network/Network/Models/PSVirtualNetwork.cs @@ -26,6 +26,8 @@ public class PSVirtualNetwork : PSTopLevelResource, IResourceReference, IVirtual public PSDhcpOptions DhcpOptions { get; set; } + public int? FlowTimeoutInMinutes { get; set; } + public List Subnets { get; set; } public PSVirtualNetworkBgpCommunities BgpCommunities { get; set; } @@ -54,6 +56,12 @@ public string DhcpOptionsText get { return JsonConvert.SerializeObject(DhcpOptions, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } } + [JsonIgnore] + public string FlowTimeoutInMinutesText + { + get { return JsonConvert.SerializeObject(FlowTimeoutInMinutes, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } + } + [JsonIgnore] public string SubnetsText { diff --git a/src/Network/Network/Network.csproj b/src/Network/Network/Network.csproj index 5decf3501563..e7586e9049d6 100644 --- a/src/Network/Network/Network.csproj +++ b/src/Network/Network/Network.csproj @@ -1,4 +1,4 @@ - + Network @@ -14,7 +14,7 @@ - + diff --git a/src/Network/Network/Network.format.ps1xml b/src/Network/Network/Network.format.ps1xml index ccc2650016d3..7235b5f8aeaf 100644 --- a/src/Network/Network/Network.format.ps1xml +++ b/src/Network/Network/Network.format.ps1xml @@ -110,6 +110,10 @@ DhcpOptionsText + + + FlowTimeoutInMinutesText + SubnetsText diff --git a/src/Network/Network/VirtualNetwork/NewAzureVirtualNetworkCommand.cs b/src/Network/Network/VirtualNetwork/NewAzureVirtualNetworkCommand.cs index cc642f24f02a..60063868745a 100644 --- a/src/Network/Network/VirtualNetwork/NewAzureVirtualNetworkCommand.cs +++ b/src/Network/Network/VirtualNetwork/NewAzureVirtualNetworkCommand.cs @@ -66,6 +66,12 @@ public class NewAzureVirtualNetworkCommand : VirtualNetworkBaseCmdlet HelpMessage = "The list of Dns Servers")] public string[] DnsServer { get; set; } + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "FlowTimeoutInMinutes")] + public int? FlowTimeoutInMinutes { get; set; } + [Parameter( Mandatory = false, ValueFromPipelineByPropertyName = true, @@ -140,6 +146,11 @@ private PSVirtualNetwork CreateVirtualNetwork() { vnet.DhcpOptions = new PSDhcpOptions {DnsServers = DnsServer?.ToList()}; } + + if (this.FlowTimeoutInMinutes > 0) + { + vnet.FlowTimeoutInMinutes = this.FlowTimeoutInMinutes; + } vnet.Subnets = this.Subnet?.ToList(); vnet.EnableDdosProtection = EnableDdosProtection; diff --git a/tools/LocalFeed/Microsoft.Azure.Management.Network.323.1255.27827.nupkg b/tools/LocalFeed/Microsoft.Azure.Management.Network.323.1255.27827.nupkg new file mode 100644 index 000000000000..e9d0303f35ac Binary files /dev/null and b/tools/LocalFeed/Microsoft.Azure.Management.Network.323.1255.27827.nupkg differ diff --git a/tools/LocalFeed/Microsoft.Azure.Management.Network.323.1255.27827.snupkg b/tools/LocalFeed/Microsoft.Azure.Management.Network.323.1255.27827.snupkg new file mode 100644 index 000000000000..10dfa1341b3a Binary files /dev/null and b/tools/LocalFeed/Microsoft.Azure.Management.Network.323.1255.27827.snupkg differ