Skip to content

Commit

Permalink
Adding VirtualRouterAutoScaleConfiguration for Route Server (#26908)
Browse files Browse the repository at this point in the history
* starting changes for ars autoscale

* update, get, and create work

* saving test progress

* updating help docs

* UT is recorded

* addressing PR comments

* updating the session record

---------

Co-authored-by: Yan Xu <yanxu1@microsoft.com>
  • Loading branch information
ksteinmeyer2023 and YanaXu authored Jan 8, 2025
1 parent 91fe3f0 commit d7173ff
Show file tree
Hide file tree
Showing 11 changed files with 1,771 additions and 1,495 deletions.
10 changes: 9 additions & 1 deletion src/Network/Network.Test/ScenarioTests/RouteServerTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ function Test-RouteServerCRUD
$skuType = "Standard"
$tier = "Regional"
$hubRoutingPreference = "VpnGateway"
$minCapacity = 6
$defaultCapacity = 2

try
{
Expand All @@ -42,6 +44,9 @@ function Test-RouteServerCRUD
$publicIp = New-AzPublicIpAddress -Name $publicIpAddressName -ResourceGroupName $rgName -AllocationMethod Static -Location $rglocation -Sku Standard -Tier Regional
$publicIp = Get-AzPublicIpAddress -Name $publicIpAddressName -ResourceGroupName $rgName

# Create the autoscale configuration
$autoscaleConfiguration = New-AzVirtualRouterAutoScaleConfiguration -MinCapacity $minCapacity

# Create route server
$actualvr = New-AzRouteServer -ResourceGroupName $rgname -location $rglocation -RouteServerName $routeServerName -HostedSubnet $hostedsubnet.Id -PublicIpAddress $publicIp -HubRoutingPreference $hubRoutingPreference -AllowBranchToBranchTraffic
$expectedvr = Get-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName
Expand All @@ -50,9 +55,10 @@ function Test-RouteServerCRUD
Assert-AreEqual $expectedvr.Location $actualvr.Location
Assert-AreEqual $expectedvr.HubRoutingPreference $actualvr.HubRoutingPreference
Assert-AreEqual $expectedvr.AllowBranchToBranchTraffic $actualvr.AllowBranchToBranchTraffic
Assert-AreEqual $defaultCapacity $actualvr.VirtualRouterAutoScaleConfiguration.MinCapacity

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

# List route servers
$list = Get-AzRouteServer -ResourceGroupName $rgname
Expand All @@ -62,6 +68,8 @@ function Test-RouteServerCRUD
Assert-AreEqual $list[0].Location $actualvr.Location
Assert-AreEqual $list[0].HubRoutingPreference $actualvr.HubRoutingPreference
Assert-AreEqual $list[0].AllowBranchToBranchTraffic $actualvr.AllowBranchToBranchTraffic
Assert-AreEqual $list[0].VirtualRouterAutoScaleConfiguration.MinCapacity $actualvr.VirtualRouterAutoScaleConfiguration.MinCapacity
Assert-AreEqual $list[0].VirtualRouterAutoScaleConfiguration.MinCapacity $minCapacity

# Delete VR
$deletevr = Remove-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName -PassThru -Force
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
--->

## Upcoming Release
* Updated `New-AzRouteServer`, `Get-AzRouteServer`, and `Update-AzRouteServer` to include VirtualRouterAutoScaleConfiguration.
* Onboarded `Microsoft.HeathDataAIServices/deidServices` to private link cmdlets
* Upgraded nuget package to signed package.
* Updated `Remove-AzNetworkWatcherFlowLog` command to return boolean value
Expand Down
2 changes: 2 additions & 0 deletions src/Network/Network/Generated/Models/PSRouteServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public PSRouteServer(PSVirtualHub virtualHub)
this.AllowBranchToBranchTraffic = virtualHub.AllowBranchToBranchTraffic;
this.PublicIpAddress = ipconfig.PublicIPAddress.Id;
this.HubRoutingPreference = virtualHub.HubRoutingPreference;
this.VirtualRouterAutoScaleConfiguration = virtualHub.VirtualRouterAutoScaleConfiguration;
}

[Ps1Xml(Target = ViewControl.Table)]
Expand All @@ -68,6 +69,7 @@ public PSRouteServer(PSVirtualHub virtualHub)
public string PublicIpAddress { get; set; }
[Ps1Xml(Target = ViewControl.Table)]
public string HubRoutingPreference { get; set; }
public PSVirtualRouterAutoScaleConfiguration VirtualRouterAutoScaleConfiguration { get; set; }

[JsonIgnore]
public string PeeringsText
Expand Down
11 changes: 11 additions & 0 deletions src/Network/Network/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Network/Network/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,9 @@
<data name="InvalidName" xml:space="preserve">
<value>Field Name {0} contains invalid character.</value>
</data>
<data name="RouteServerToUpdateNotFound" xml:space="preserve">
<value>The Route Server to update could not be found.</value>
</data>
<data name="VirtualHubToUpdateNotFound" xml:space="preserve">
<value>The VirtualHub to update could not be found.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ public partial class NewAzureRmRouteServer : RouteServerBaseCmdlet
[PSDefaultValue(Value=false)]
public SwitchParameter AllowBranchToBranchTraffic { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Autoscale configuration for route server.")]
public PSVirtualRouterAutoScaleConfiguration VirtualRouterAutoScaleConfiguration { get; set; }

public override void Execute()
{
base.Execute();
Expand Down Expand Up @@ -133,7 +138,8 @@ public override void Execute()
{
ResourceGroupName = this.ResourceGroupName,
Name = this.RouteServerName,
Location = this.Location
Location = this.Location,
VirtualRouterAutoScaleConfiguration = this.VirtualRouterAutoScaleConfiguration
};

if (string.IsNullOrWhiteSpace(this.HubRoutingPreference))
Expand Down
35 changes: 23 additions & 12 deletions src/Network/Network/RouteServer/UpdateAzureRMRouteServerCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public partial class UpdateAzureRmRouteServer : RouteServerBaseCmdlet
IgnoreCase = true)]
public string HubRoutingPreference { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Autoscale configuration for route server.")]
public PSVirtualRouterAutoScaleConfiguration VirtualRouterAutoScaleConfiguration { get; set; }

public override void Execute()
{
base.Execute();
Expand All @@ -94,29 +99,35 @@ public override void Execute()
this.RouteServerName = resourceInfo.ResourceName;
}

var virtualHub = this.NetworkClient.NetworkManagementClient.VirtualHubs.Get(ResourceGroupName, RouteServerName);
var routeServer = this.NetworkClient.NetworkManagementClient.VirtualHubs.Get(ResourceGroupName, RouteServerName);
PSVirtualHub routeServerToUpdate = this.ToPsVirtualHub(routeServer) ?? throw new PSArgumentException(Properties.Resources.RouteServerToUpdateNotFound);

if (this.AllowBranchToBranchTraffic.HasValue)
{
virtualHub.AllowBranchToBranchTraffic = this.AllowBranchToBranchTraffic.Value;
routeServerToUpdate.AllowBranchToBranchTraffic = this.AllowBranchToBranchTraffic.Value;
}

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

if (this.VirtualRouterAutoScaleConfiguration != null)
{
routeServerToUpdate.VirtualRouterAutoScaleConfiguration = this.VirtualRouterAutoScaleConfiguration;
}

this.NetworkClient.NetworkManagementClient.VirtualHubs.CreateOrUpdate(this.ResourceGroupName, this.RouteServerName, virtualHub);
var routeServerModel = NetworkResourceManagerProfile.Mapper.Map<MNM.VirtualHub>(routeServerToUpdate);
this.NetworkClient.NetworkManagementClient.VirtualHubs.CreateOrUpdate(this.ResourceGroupName, this.RouteServerName, routeServerModel);

var psVirtualHub = NetworkResourceManagerProfile.Mapper.Map<CNM.PSVirtualHub>(virtualHub);
psVirtualHub.ResourceGroupName = this.ResourceGroupName;
psVirtualHub.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags);
AddBgpConnectionsToPSVirtualHub(psVirtualHub, ResourceGroupName, RouteServerName);
AddIpConfigurtaionToPSVirtualHub(psVirtualHub, this.ResourceGroupName, RouteServerName);
routeServerToUpdate.ResourceGroupName = this.ResourceGroupName;
routeServerToUpdate.Tag = TagsConversionHelper.CreateTagHashtable(routeServer.Tags);
AddBgpConnectionsToPSVirtualHub(routeServerToUpdate, ResourceGroupName, RouteServerName);
AddIpConfigurtaionToPSVirtualHub(routeServerToUpdate, this.ResourceGroupName, RouteServerName);

var routeServerModel = new PSRouteServer(psVirtualHub);
routeServerModel.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags);
WriteObject(routeServerModel, true);
var routeServerPSModel = new PSRouteServer(routeServerToUpdate);
routeServerPSModel.Tag = TagsConversionHelper.CreateTagHashtable(routeServer.Tags);
WriteObject(routeServerPSModel, true);
}
}
}
12 changes: 12 additions & 0 deletions src/Network/Network/VirtualRouter/RouteServerBaseCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using Microsoft.Azure.Management.Network.Models;
using CNM = Microsoft.Azure.Commands.Network.Models;
using System.Collections.Generic;
using Microsoft.Azure.Commands.Network.Models;
using System;
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;

namespace Microsoft.Azure.Commands.Network
{
Expand Down Expand Up @@ -37,5 +40,14 @@ public void AddIpConfigurtaionToPSVirtualHub(CNM.PSVirtualHub virtualHubModel,
virtualHubModel.IpConfigurations = new List<CNM.PSHubIpConfiguration>();
virtualHubModel.IpConfigurations.Add(ipconfig);
}

public PSVirtualHub ToPsVirtualHub(Management.Network.Models.VirtualHub virtualHub)
{
var psVirtualHub = NetworkResourceManagerProfile.Mapper.Map<PSVirtualHub>(virtualHub);

psVirtualHub.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags);

return psVirtualHub;
}
}
}
40 changes: 37 additions & 3 deletions src/Network/Network/help/New-AzRouteServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ Creates an Azure RouteServer.
```
New-AzRouteServer -ResourceGroupName <String> -RouteServerName <String> -HostedSubnet <String>
[-PublicIpAddress <PSPublicIpAddress>] -Location <String> [-Tag <Hashtable>] [-Force] [-AsJob]
[-HubRoutingPreference <String>] [-AllowBranchToBranchTraffic] [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
[-HubRoutingPreference <String>] [-AllowBranchToBranchTraffic]
[-VirtualRouterAutoScaleConfiguration <PSVirtualRouterAutoScaleConfiguration>]
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

## DESCRIPTION
The **New-AzRouteServer** cmdlet creates an Azure RouteServer

## EXAMPLES

### Example 1: Create a new router server
### Example 1
```powershell
New-AzResourceGroup -Name myResourceGroup -Location eastus
Expand All @@ -35,6 +37,23 @@ $publicIpAddress = New-AzPublicIpAddress -Name myRouteServerIP -ResourceGroupNam
New-AzRouteServer -RouteServerName myRouteServer -ResourceGroupName myResourceGroup -Location eastus -HostedSubnet $subnetId -PublicIpAddress $publicIpAddress
```
The above will create a resource group "myResourceGroup", a Virtual Network with a RouteServerSubnet, a Public IP Address, and a Route Server in East US in that resource group in Azure. The Route Server will be created with the default settings.

### Example 2
```powershell
New-AzResourceGroup -Name myResourceGroup -Location eastus
$subnet = New-AzVirtualNetworkSubnetConfig -Name RouteServerSubnet -AddressPrefix 10.0.0.0/24
$vnet = New-AzVirtualNetwork -Name myVNet -ResourceGroupName myResourceGroup -Location eastus -AddressPrefix 10.0.0.0/16 -Subnet $subnet
$subnetId = (Get-AzVirtualNetworkSubnetConfig -Name RouteServerSubnet -VirtualNetwork $vnet).Id
$publicIpAddress = New-AzPublicIpAddress -Name myRouteServerIP -ResourceGroupName myResourceGroup -AllocationMethod Static -Location eastus -Sku Standard -Tier Regional
$autoscale = New-AzVirtualRouterAutoScaleConfiguration -MinCapacity 3
New-AzRouteServer -RouteServerName myRouteServer -ResourceGroupName myResourceGroup -Location eastus -HostedSubnet $subnetId -PublicIpAddress $publicIpAddress -VirtualRouterAutoScaleConfiguration $autoscale
```
The above will create a resource group "myResourceGroup", a Virtual Network with a RouteServerSubnet, a Public IP Address, and a Route Server in East US in that resource group in Azure.

This example is similar to Example 2, but the Route Server will be created with a minCapacity of 3 meaning that it will have 3 Routing Infrastructure Units.

## PARAMETERS

Expand Down Expand Up @@ -204,6 +223,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -VirtualRouterAutoScaleConfiguration
Autoscale configuration for route server.
```yaml
Type: Microsoft.Azure.Commands.Network.Models.PSVirtualRouterAutoScaleConfiguration
Parameter Sets: (All)
Aliases:

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
31 changes: 29 additions & 2 deletions src/Network/Network/help/Update-AzRouteServer.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ Update an Azure RouteServer.
```
Update-AzRouteServer -ResourceGroupName <String> -RouteServerName <String>
[-AllowBranchToBranchTraffic <Boolean>] [-HubRoutingPreference <String>]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-VirtualRouterAutoScaleConfiguration <PSVirtualRouterAutoScaleConfiguration>]
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### RouteServerResourceIdParameterSet
```
Update-AzRouteServer [-AllowBranchToBranchTraffic <Boolean>] -ResourceId <String>
[-HubRoutingPreference <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[-HubRoutingPreference <String>]
[-VirtualRouterAutoScaleConfiguration <PSVirtualRouterAutoScaleConfiguration>]
[-DefaultProfile <IAzureContextContainer>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

Expand Down Expand Up @@ -52,6 +56,14 @@ Update-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerNam

To change routing preference for route server.

### Example 4
```powershell
$autoscale = New-AzVirtualRouterAutoScaleConfiguration -MinCapacity 3
Update-AzRouteServer -ResourceGroupName $rgname -RouteServerName $routeServerName -VirtualRouterAutoScaleConfiguration $autoscale
```

To update the Routing Infrastructure Units to 3.

## PARAMETERS

### -AllowBranchToBranchTraffic
Expand Down Expand Up @@ -145,6 +157,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: True
```
### -VirtualRouterAutoScaleConfiguration
Autoscale configuration for route server.
```yaml
Type: Microsoft.Azure.Commands.Network.Models.PSVirtualRouterAutoScaleConfiguration
Parameter Sets: (All)
Aliases:

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

0 comments on commit d7173ff

Please sign in to comment.