Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HubRoutingPreference as an optional command in New-AzRouteServer and Update-AzRouteServer #18252

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
3 changes: 3 additions & 0 deletions src/Network/Network.Test/ScenarioTests/RouteServerTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function Test-RouteServerCRUD
Assert-AreEqual $expectedvr.Name $actualvr.Name
Assert-AreEqual $expectedvr.Location $actualvr.Location

# Update route server
$actualvr = Update-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName -HubRoutingPreference "ASPath"

# List route servers
$list = Get-AzRouteServer -ResourceGroupName $rgname
Assert-AreEqual 1 @($list).Count
Expand Down

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 @@ -40,6 +40,9 @@
- `New-AzVpnServerConfigurationPolicyGroup`
- `Update-AzVpnServerConfigurationPolicyGroup`
- `Remove-AzVpnServerConfigurationPolicyGroup`
* Updated cmdlets to add new option of `HubRoutingPreference` in RouteServer.
- `New-AzRouteServer`
- `Update-AzRouteServer`

## Version 4.16.1
* Fixed `ArgumentNullException` in `Add-AzureRmRouteConfig` when `RouteTable.Routes` is null.
Expand Down
19 changes: 19 additions & 0 deletions src/Network/Network/RouteServer/NewAzureRMRouteServerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ public partial class NewAzureRmRouteServer : RouteServerBaseCmdlet
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Routing Preference to route traffic")]
[ValidateSet(
MNM.HubRoutingPreference.ExpressRoute,
MNM.HubRoutingPreference.VpnGateway,
MNM.HubRoutingPreference.ASPath,
IgnoreCase = true)]
public string HubRoutingPreference { get; set; }

public override void Execute()
{
base.Execute();
Expand Down Expand Up @@ -120,6 +130,15 @@ public override void Execute()
Location = this.Location
};

if (string.IsNullOrWhiteSpace(this.HubRoutingPreference))
{
virtualHub.HubRoutingPreference = "ExpressRoute";
}
else
{
virtualHub.HubRoutingPreference = this.HubRoutingPreference;
}

var publicIpAddressModel = NetworkResourceManagerProfile.Mapper.Map<PublicIPAddress>(this.PublicIpAddress);
virtualHub.RouteTables = new List<PSVirtualHubRouteTable>();
string ipConfigName = "ipconfig1";
Expand Down
17 changes: 17 additions & 0 deletions src/Network/Network/RouteServer/UpdateAzureRMRouteServerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System;
using System.Management.Automation;
using CNM = Microsoft.Azure.Commands.Network.Models;
using MNM = Microsoft.Azure.Management.Network.Models;
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;

namespace Microsoft.Azure.Commands.Network
Expand Down Expand Up @@ -67,6 +68,16 @@ public partial class UpdateAzureRmRouteServer : RouteServerBaseCmdlet
[ResourceIdCompleter("Microsoft.Network/virtualHubs")]
public string ResourceId { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Virtual Hub Routing Preference to route traffic")]
[ValidateSet(
MNM.HubRoutingPreference.ExpressRoute,
MNM.HubRoutingPreference.VpnGateway,
MNM.HubRoutingPreference.ASPath,
IgnoreCase = true)]
public string HubRoutingPreference { get; set; }

public override void Execute()
{
base.Execute();
Expand All @@ -80,6 +91,12 @@ public override void Execute()

var virtualHub = this.NetworkClient.NetworkManagementClient.VirtualHubs.Get(ResourceGroupName, RouteServerName);
virtualHub.AllowBranchToBranchTraffic = this.AllowBranchToBranchTraffic.IsPresent;

if (!string.IsNullOrWhiteSpace(this.HubRoutingPreference))
{
virtualHub.HubRoutingPreference = this.HubRoutingPreference;
}

this.NetworkClient.NetworkManagementClient.VirtualHubs.CreateOrUpdate(this.ResourceGroupName, this.RouteServerName, virtualHub);

var psVirtualHub = NetworkResourceManagerProfile.Mapper.Map<CNM.PSVirtualHub>(virtualHub);
Expand Down
19 changes: 17 additions & 2 deletions src/Network/Network/help/New-AzRouteServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Creates an Azure RouteServer.

```
New-AzRouteServer -ResourceGroupName <String> -RouteServerName <String> -HostedSubnet <String>
[-PublicIpAddress <PSPublicIpAddress>] -Location <String> [-Tag <Hashtable>] [-Force] [-AsJob]
[-PublicIpAddress <PSPublicIpAddress>] -Location <String> [-Tag <Hashtable>] [-HubRoutingPreference <String>] [-Force] [-AsJob]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

Expand All @@ -30,7 +30,7 @@ $vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroupNa
$subnetId = (Get-AzVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet).Id
$publicIpAddress = New-AzPublicIpAddress -Name $publicIpAddressName -ResourceGroupName $rgName -AllocationMethod Static -Location $rglocation -Sku Standard -Tier Regional

New-AzRouteServer -RouteServerName $routeServerName -ResourceGroupName $resourceGroupName -Location $resourceGroupLocation -HostedSubnet $subnetId -PublicIpAddress $publicIpAddress
New-AzRouteServer -RouteServerName $routeServerName -ResourceGroupName $resourceGroupName -Location $resourceGroupLocation -HostedSubnet $subnetId -PublicIpAddress $publicIpAddress -HubRoutingPreference "AsPath"
```

## PARAMETERS
Expand Down Expand Up @@ -170,6 +170,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -HubRoutingPreference
Routing Preference to route traffic

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:
Accepted values: ExpressRoute, VpnGateway, ASPath
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

Expand Down
27 changes: 24 additions & 3 deletions src/Network/Network/help/Update-AzRouteServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ Update an Azure RouteServer.

### RouteServerNameParameterSet (Default)
```
Update-AzRouteServer -ResourceGroupName <String> -RouteServerName <String> [-AllowBranchToBranchTraffic]
Update-AzRouteServer -ResourceGroupName <String> -RouteServerName <String> [-AllowBranchToBranchTraffic] [-HubRoutingPreference <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### RouteServerResourceIdParameterSet
```
Update-AzRouteServer [-AllowBranchToBranchTraffic] -ResourceId <String>
Update-AzRouteServer [-AllowBranchToBranchTraffic] -ResourceId <String> [-HubRoutingPreference <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

Expand All @@ -35,12 +35,18 @@ Update-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerNam
```
To enable branch to branch traffic for route server.

### Example 1
### Example 2
```powershell
Update-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName
```
To disable branch to branch traffic for route server.

### Example 3
```powershell
Update-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName -HubRoutingPreference "AsPath"
```
To change routing preference for route server.

## PARAMETERS

### -AllowBranchToBranchTraffic
Expand Down Expand Up @@ -118,6 +124,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -HubRoutingPreference
Routing Preference to route traffic

```yaml
Type: System.String
Parameter Sets: (All)
Aliases:
Accepted values: ExpressRoute, VpnGateway, ASPath
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Confirm
Prompts you for confirmation before running the cmdlet.

Expand Down