Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Network/Network.Test/ScenarioTests/RouteTableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,13 @@ public void TestRouteWithDisableBgpRoutePropagation()
{
TestRunner.RunTestScript("Test-RouteTableWithDisableBgpRoutePropagation");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.nsgdev)]
public void TestRouteWithDisablePeeringRoute()
{
TestRunner.RunTestScript("Test-RouteTableWithDisablePeeringRoute");
}
}
}
60 changes: 60 additions & 0 deletions src/Network/Network.Test/ScenarioTests/RouteTableTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,64 @@ function Test-RouteTableWithDisableBgpRoutePropagation
# Cleanup
Clean-ResourceGroup $rgname
}
}

<#
.SYNOPSIS
Tests RouteTableWithDisablePeeringRoute.
#>
function Test-RouteTableWithDisablePeeringRoute
{
# Setup
$rgname = Get-ResourceGroupName
$routeTableName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/routeTables"
# Currently only the Central US EUAP canary region has the DisablePeeringRoute feature enabled, so hardcoding it to this region. This can be removed once it is enabled on production regions.
$location = Get-ProviderLocation $resourceTypeParent "centraluseuap"

try
{
# Create the resource group
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" }

# Create RouteTable with DisablePeeringRoute set to "All"
$rt = New-AzRouteTable -name $routeTableName -DisablePeeringRoute "All" -ResourceGroupName $rgname -Location $location

# Get RouteTable
$getRT = Get-AzRouteTable -name $routeTableName -ResourceGroupName $rgName

#verification
Assert-AreEqual $rgName $getRT.ResourceGroupName
Assert-AreEqual $routeTableName $getRT.Name
Assert-AreEqual "All" $getRT.DisablePeeringRoute
Assert-NotNull $getRT.Etag
Assert-AreEqual 0 @($getRT.Routes).Count

# list
$list = Get-AzRouteTable -ResourceGroupName $rgname
Assert-AreEqual 1 @($list).Count
Assert-AreEqual $list[0].ResourceGroupName $getRT.ResourceGroupName
Assert-AreEqual $list[0].Name $getRT.Name
# Note: the route tables list endpoint (GET .../routeTables) does not project the DisablePeeringRoute property; it is only returned by the single-resource GET (.../routeTables/{name}). So DisablePeeringRoute is intentionally not asserted on the list result.
Assert-AreEqual $list[0].Etag $getRT.Etag
Assert-AreEqual @($list[0].Routes).Count @($getRT.Routes).Count

# Update to "None"
$getRT.DisablePeeringRoute = "None"
$updatedRT = Set-AzRouteTable -RouteTable $getRT
Assert-AreEqual "None" $updatedRT.DisablePeeringRoute

# Delete RouteTable
$delete = Remove-AzRouteTable -ResourceGroupName $rgname -name $routeTableName -PassThru -Force
Assert-AreEqual true $delete

$list = Get-AzRouteTable -ResourceGroupName $rgname
Assert-AreEqual 0 @($list).Count
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
--->

## Upcoming Release
* Added DisablePeeringRoute support for Route Table
- Added `-DisablePeeringRoute` parameter to `New-AzRouteTable` cmdlet
- Supported values are `None` and `All`
* Added property 'Nat64' to NatGateway and support for it in the following cmdlets:
- `New-AzNatGateway`
- `Set-AzNatGateway`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public partial class NewAzureRmRouteTable : NetworkBaseCmdlet
HelpMessage = "Gets or sets whether to disable the routes learned by BGP on that route table. True means disable.")]
public SwitchParameter DisableBgpRoutePropagation { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Whether to disable the routes learned by peering on the route table. 'None' means that peering routes will be present. 'All' means that all peering routes will be dropped.",
ValueFromPipelineByPropertyName = true)]
[PSArgumentCompleter("None", "All")]
public string DisablePeeringRoute { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "The location.",
Expand Down Expand Up @@ -100,6 +107,7 @@ public override void Execute()
var vRouteTable = new PSRouteTable
{
DisableBgpRoutePropagation = this.DisableBgpRoutePropagation,
DisablePeeringRoute = this.DisablePeeringRoute,
Location = this.Location,
Routes = this.Route?.ToList(),
};
Expand Down
3 changes: 3 additions & 0 deletions src/Network/Network/Models/PSRouteTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class PSRouteTable : PSTopLevelResource
[Ps1Xml(Target = ViewControl.Table)]
public bool DisableBgpRoutePropagation { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public string DisablePeeringRoute { get; set; }

[JsonIgnore]
public string RoutesText
{
Expand Down
17 changes: 16 additions & 1 deletion src/Network/Network/help/New-AzRouteTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Creates a route table.
## SYNTAX

```
New-AzRouteTable -ResourceGroupName <String> -Name <String> [-DisableBgpRoutePropagation] -Location <String>
New-AzRouteTable -ResourceGroupName <String> -Name <String> [-DisableBgpRoutePropagation] [-DisablePeeringRoute <String>] -Location <String>
[-Tag <Hashtable>] [-Route <PSRoute[]>] [-Force] [-AsJob] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [-AcquirePolicyToken] [-ChangeReference <String>]
[<CommonParameters>]
Expand Down Expand Up @@ -138,6 +138,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -DisablePeeringRoute
Specifies whether to disable peering routes. Valid values are None and All.

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -Force
Indicates that this cmdlet creates a route table even if a route table that has the same name already exists.

Expand Down