diff --git a/src/Network/Network.Test/ScenarioTests/CortexTests.ps1 b/src/Network/Network.Test/ScenarioTests/CortexTests.ps1 index 80fed57a47dc..a5774d3bcf68 100644 --- a/src/Network/Network.Test/ScenarioTests/CortexTests.ps1 +++ b/src/Network/Network.Test/ScenarioTests/CortexTests.ps1 @@ -68,7 +68,7 @@ function Test-CortexCRUD Assert-NotNull $virtualWansAll # Create the Virtual Hub - $createdVirtualHub = New-AzVirtualHub -ResourceGroupName $rgName -Name $virtualHubName -Location $rglocation -AddressPrefix "192.168.1.0/24" -VirtualWan $virtualWan + $createdVirtualHub = New-AzVirtualHub -ResourceGroupName $rgName -Name $virtualHubName -Location $rglocation -AddressPrefix "192.168.1.0/24" -VirtualWan $virtualWan -HubRoutingPreference "ASPath" $virtualHub = Get-AzVirtualHub -ResourceGroupName $rgName -Name $virtualHubName Assert-AreEqual $rgName $virtualHub.ResourceGroupName Assert-AreEqual $virtualHubName $virtualHub.Name @@ -94,7 +94,7 @@ function Test-CortexCRUD $route1 = New-AzVirtualHubRoute -AddressPrefix @("10.0.0.0/16", "11.0.0.0/16") -NextHopIpAddress "12.0.0.5" $route2 = New-AzVirtualHubRoute -AddressPrefix @("13.0.0.0/16") -NextHopIpAddress "14.0.0.5" $routeTable = New-AzVirtualHubRouteTable -Route @($route1, $route2) - Update-AzVirtualHub -ResourceGroupName $rgName -Name $virtualHubName -RouteTable $routeTable + Update-AzVirtualHub -ResourceGroupName $rgName -Name $virtualHubName -RouteTable $routeTable -HubRoutingPreference "ExpressRoute" $virtualHub = Get-AzVirtualHub -ResourceGroupName $rgName -Name $virtualHubName Assert-AreEqual $rgName $virtualHub.ResourceGroupName Assert-AreEqual $virtualHubName $virtualHub.Name diff --git a/src/Network/Network/ChangeLog.md b/src/Network/Network/ChangeLog.md index fab4e14a0e97..43c9fbec7d11 100644 --- a/src/Network/Network/ChangeLog.md +++ b/src/Network/Network/ChangeLog.md @@ -26,6 +26,9 @@ * Added option parameter `AuthorizationKey` to cmdlet `New-AzExpressRouteCircuit` to allow creating ExpressRoute Circuit on a ExpressRoutePort with a different owner. * Fixed `ArgumentNullException` in `Add-AzureRmRouteConfig` when `RouteTable.Routes` is null. * Fix bug that can't display CustomIpPrefix in PublicIpPrefix. +* Updated cmdlets to add new property of `HubRoutingPreference` in VirtualHub and set property of `PreferredRoutingGateway` deprecated . + - `New-AzVirtualHub` + - `Update-AzVirtualHub` ## Version 4.16.0 * Added support for retrieving the state of packet capture even when the provisioning state of the packet capture was failure diff --git a/src/Network/Network/Cortex/CortexParameterSetNames.cs b/src/Network/Network/Cortex/CortexParameterSetNames.cs index f3e93de08d95..19a4b9d508fa 100644 --- a/src/Network/Network/Cortex/CortexParameterSetNames.cs +++ b/src/Network/Network/Cortex/CortexParameterSetNames.cs @@ -84,5 +84,5 @@ internal static class CortexParameterSetNames internal const string ByHubBgpConnectionObject = "ByHubBgpConnectionObject"; internal const string ByHubBgpConnectionResourceId = "ByHubBgpConnectionResourceId"; - } + } } \ No newline at end of file diff --git a/src/Network/Network/Cortex/VirtualHub/NewAzureRmVirtualHubCommand.cs b/src/Network/Network/Cortex/VirtualHub/NewAzureRmVirtualHubCommand.cs index bd828c445697..a2ceef5d8a67 100644 --- a/src/Network/Network/Cortex/VirtualHub/NewAzureRmVirtualHubCommand.cs +++ b/src/Network/Network/Cortex/VirtualHub/NewAzureRmVirtualHubCommand.cs @@ -98,6 +98,8 @@ public class NewAzureRmVirtualHubCommand : VirtualHubBaseCmdlet [PSArgumentCompleter("Basic", "Standard")] public string Sku { get; set; } + public const String PreferredGWChangeDesc = "PreferredRoutingGateway parameter is deprecated. Use *HubRoutingPreference* property"; + [CmdletParameterBreakingChange("PreferredRoutingGateway", ChangeDescription = PreferredGWChangeDesc)] [Parameter( Mandatory = false, HelpMessage = "Preferred Routing Gateway to Route On-Prem traffic from VNET")] @@ -107,6 +109,16 @@ public class NewAzureRmVirtualHubCommand : VirtualHubBaseCmdlet IgnoreCase = true)] public string PreferredRoutingGateway { 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; } + [Parameter( Mandatory = false, HelpMessage = "Run cmdlet in the background")] @@ -183,6 +195,15 @@ public override void Execute() virtualHub.PreferredRoutingGateway = this.PreferredRoutingGateway; } + if (string.IsNullOrWhiteSpace(this.HubRoutingPreference)) + { + virtualHub.HubRoutingPreference = "ExpressRoute"; + } + else + { + virtualHub.HubRoutingPreference = this.HubRoutingPreference; + } + WriteObject(CreateOrUpdateVirtualHub( this.ResourceGroupName, this.Name, diff --git a/src/Network/Network/Cortex/VirtualHub/UpdateAzureRmVirtualHubCommand.cs b/src/Network/Network/Cortex/VirtualHub/UpdateAzureRmVirtualHubCommand.cs index 5a001900547a..bb08017f0d75 100644 --- a/src/Network/Network/Cortex/VirtualHub/UpdateAzureRmVirtualHubCommand.cs +++ b/src/Network/Network/Cortex/VirtualHub/UpdateAzureRmVirtualHubCommand.cs @@ -103,6 +103,8 @@ public class UpdateAzureRmVirtualHubCommand : VirtualHubBaseCmdlet [PSArgumentCompleter("Basic", "Standard")] public string Sku { get; set; } + public const String PreferredGWChangeDesc = "PreferredRoutingGateway parameter will be deprecated. Use *HubRoutingPreference* parameter"; + [CmdletParameterBreakingChange("PreferredRoutingGateway", ChangeDescription = PreferredGWChangeDesc)] [Parameter( Mandatory = false, HelpMessage = "Preferred Routing Gateway to Route On-Prem traffic from VNET")] @@ -112,6 +114,16 @@ public class UpdateAzureRmVirtualHubCommand : VirtualHubBaseCmdlet IgnoreCase = true)] public string PreferredRoutingGateway { 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; } + [Parameter( Mandatory = false, HelpMessage = "Run cmdlet in the background")] @@ -194,6 +206,11 @@ public override void Execute() virtualHubToUpdate.PreferredRoutingGateway = this.PreferredRoutingGateway; } + if (!string.IsNullOrWhiteSpace(this.HubRoutingPreference)) + { + virtualHubToUpdate.HubRoutingPreference = this.HubRoutingPreference; + } + //// Update the virtual hub ConfirmAction( Properties.Resources.SettingResourceMessage, diff --git a/src/Network/Network/Cortex/VirtualHub/VirtualHubBaseCmdlet.cs b/src/Network/Network/Cortex/VirtualHub/VirtualHubBaseCmdlet.cs index 2cf819721549..2e83769a0b7b 100644 --- a/src/Network/Network/Cortex/VirtualHub/VirtualHubBaseCmdlet.cs +++ b/src/Network/Network/Cortex/VirtualHub/VirtualHubBaseCmdlet.cs @@ -51,7 +51,7 @@ public IVirtualHubsOperations VirtualHubClient public PSVirtualHub ToPsVirtualHub(Management.Network.Models.VirtualHub virtualHub) { var psVirtualHub = NetworkResourceManagerProfile.Mapper.Map(virtualHub); - + psVirtualHub.Tag = TagsConversionHelper.CreateTagHashtable(virtualHub.Tags); return psVirtualHub; diff --git a/src/Network/Network/Cortex/VpnConnection/UpdateAzureRmVpnConnectionCommand.cs b/src/Network/Network/Cortex/VpnConnection/UpdateAzureRmVpnConnectionCommand.cs index 3e91cec575d7..50b0b5c09117 100644 --- a/src/Network/Network/Cortex/VpnConnection/UpdateAzureRmVpnConnectionCommand.cs +++ b/src/Network/Network/Cortex/VpnConnection/UpdateAzureRmVpnConnectionCommand.cs @@ -240,7 +240,7 @@ public override void Execute() throw new PSArgumentException(Properties.Resources.StaticRoutesNotSupportedForThisRoutingConfiguration); } - vpnConnectionToModify.RoutingConfiguration = RoutingConfiguration; + vpnConnectionToModify.RoutingConfiguration = this.RoutingConfiguration; } if(!String.IsNullOrEmpty(this.VpnLinkConnectionMode)) diff --git a/src/Network/Network/Models/Cortex/PSVirtualHub.cs b/src/Network/Network/Models/Cortex/PSVirtualHub.cs index 094c0b242ccf..1296b674a4f7 100644 --- a/src/Network/Network/Models/Cortex/PSVirtualHub.cs +++ b/src/Network/Network/Models/Cortex/PSVirtualHub.cs @@ -63,5 +63,8 @@ public class PSVirtualHub : PSTopLevelResource [Ps1Xml(Label = "Preferred Routing Gateway", Target = ViewControl.Table)] public string PreferredRoutingGateway { get; set; } + + [Ps1Xml(Label = "Hub Routing Preference", Target = ViewControl.Table)] + public string HubRoutingPreference { get; set; } } } \ No newline at end of file diff --git a/src/Network/Network/Network.format.ps1xml b/src/Network/Network/Network.format.ps1xml index ca3199824528..81a7c66a5561 100644 --- a/src/Network/Network/Network.format.ps1xml +++ b/src/Network/Network/Network.format.ps1xml @@ -4491,6 +4491,10 @@ PreferredRoutingGateway + + + HubRoutingPreference + ProvisioningState diff --git a/src/Network/Network/help/New-AzVirtualHub.md b/src/Network/Network/help/New-AzVirtualHub.md index b86cb10b9f03..d2dabe70d688 100644 --- a/src/Network/Network/help/New-AzVirtualHub.md +++ b/src/Network/Network/help/New-AzVirtualHub.md @@ -17,7 +17,7 @@ Creates an Azure VirtualHub resource. New-AzVirtualHub -ResourceGroupName -Name -VirtualWan -AddressPrefix -Location [-HubVnetConnection ] [-RouteTable ] [-Tag ] [-Sku ] [-PreferredRoutingGateway ] - [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-HubRoutingPreference ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByVirtualWanResourceId @@ -25,7 +25,7 @@ New-AzVirtualHub -ResourceGroupName -Name -VirtualWan -Name -VirtualWanId -AddressPrefix -Location [-HubVnetConnection ] [-RouteTable ] [-Tag ] [-Sku ] [-PreferredRoutingGateway ] - [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-HubRoutingPreference ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -53,6 +53,7 @@ RouteTables : {} Location : West US Sku : Standard PreferredRoutingGateway : ExpressRoute +HubRoutingPreference : ExpressRoute Type : Microsoft.Network/virtualHubs ProvisioningState : Succeeded ``` @@ -79,6 +80,7 @@ RouteTables : {} Location : West US Sku : Standard PreferredRoutingGateway : ExpressRoute +HubRoutingPreference : ExpressRoute Type : Microsoft.Network/virtualHubs ProvisioningState : Succeeded ``` @@ -110,6 +112,7 @@ RouteTables : {} Location : West US Sku : Standard PreferredRoutingGateway : ExpressRoute +HubRoutingPreference : ExpressRoute Type : Microsoft.Network/virtualHubs ProvisioningState : Succeeded ``` @@ -123,9 +126,10 @@ This example is similar to Example 2, but also attaches a route table to the vir ```powershell New-AzResourceGroup -Location "West US" -Name "testRG" $virtualWan = New-AzVirtualWan -ResourceGroupName "testRG" -Name "myVirtualWAN" -Location "West US" -New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.1.0/24" -PreferredRoutingGateway "VpnGateway" +New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.1.0/24" -HubRoutingPreference "VpnGateway" ``` + ```output VirtualWan : /subscriptions/{subscriptionId}resourceGroups/testRG/providers/Microsoft.Network/virtualWans/myVirtualWAN ResourceGroupName : testRG @@ -135,7 +139,7 @@ AddressPrefix : 10.0.1.0/24 RouteTable : Location : West US Sku : Standard -PreferredRoutingGateway : VpnGateway +HubRoutingPreference : VpnGateway VirtualNetworkConnections : {} Location : West US Type : Microsoft.Network/virtualHubs @@ -237,7 +241,7 @@ Accept wildcard characters: False ``` ### -PreferredRoutingGateway -Preferred Routing Gateway to Route On-Prem traffic from VNET +Preferred Routing Gateway to Route On-Prem traffic from VNET (Deprecated, please use HubRoutingPreference) ```yaml Type: System.String @@ -252,6 +256,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -HubRoutingPreference +Virtual Hub 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 +``` + ### -ResourceGroupName The resource group name. diff --git a/src/Network/Network/help/Update-AzVirtualHub.md b/src/Network/Network/help/Update-AzVirtualHub.md index bdac30835024..e2e90cbd421c 100644 --- a/src/Network/Network/help/Update-AzVirtualHub.md +++ b/src/Network/Network/help/Update-AzVirtualHub.md @@ -16,24 +16,24 @@ Updates a virtual hub. ``` Update-AzVirtualHub -ResourceGroupName -Name [-AddressPrefix ] [-HubVnetConnection ] [-RouteTable ] - [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-AsJob] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-HubRoutingPreference ] + [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByVirtualHubResourceId ``` Update-AzVirtualHub -ResourceId [-AddressPrefix ] [-HubVnetConnection ] [-RouteTable ] - [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-AsJob] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-HubRoutingPreference ] + [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByVirtualHubObject ``` Update-AzVirtualHub -InputObject [-AddressPrefix ] [-HubVnetConnection ] [-RouteTable ] - [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-AsJob] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-HubRoutingPreference ] + [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -101,7 +101,7 @@ This example is similar to Example 1, but also attaches a route table to the vir New-AzResourceGroup -Location "West US" -Name "testRG" $virtualWan = New-AzVirtualWan -ResourceGroupName "testRG" -Name "myVirtualWAN" -Location "West US" New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.1.0/24" -Update-AzVirtualHub -ResourceGroupName "testRG" -Name "westushub" -PreferredRoutingGateway "VpnGateway" +Update-AzVirtualHub -ResourceGroupName "testRG" -Name "westushub" -HubRoutingPreference "VpnGateway" ``` ```output @@ -113,7 +113,7 @@ AddressPrefix : 10.0.1.0/24 RouteTable : Location : West US Sku : Standard -PreferredRoutingGateway : VpnGateway +HubRoutingPreference : VpnGateway VirtualNetworkConnections : {} Location : West US Type : Microsoft.Network/virtualHubs @@ -215,7 +215,7 @@ Accept wildcard characters: False ``` ### -PreferredRoutingGateway -Preferred Routing Gateway to Route On-Prem traffic from VNET +Preferred Routing Gateway to Route On-Prem traffic from VNET (Deprecated, please use HubRoutingPreference) ```yaml Type: System.String @@ -230,6 +230,22 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -HubRoutingPreference +Virtual Hub 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 +``` + ### -ResourceGroupName The resource group name.