diff --git a/src/Network/Network/ChangeLog.md b/src/Network/Network/ChangeLog.md index 0ebe4ed0d556..26b3203a5de4 100644 --- a/src/Network/Network/ChangeLog.md +++ b/src/Network/Network/ChangeLog.md @@ -33,6 +33,9 @@ - `Update-AzVirtualNetworkGatewayNatRule` - `Get-AzVirtualNetworkGatewayNatRule` - `Remove-AzVirtualNetworkGatewayNatRule` +* Updated cmdlets to enable setting of PreferredRoutingGateway on VirtualHub. + - `New-AzVirtualHub` + - `Update-AzVirtualHub` ## Version 4.7.0 * Added new cmdlets to replace old product name `virtual router` with new name `route server` in the future. diff --git a/src/Network/Network/Cortex/VirtualHub/NewAzureRmVirtualHubCommand.cs b/src/Network/Network/Cortex/VirtualHub/NewAzureRmVirtualHubCommand.cs index a03f9de97457..bd828c445697 100644 --- a/src/Network/Network/Cortex/VirtualHub/NewAzureRmVirtualHubCommand.cs +++ b/src/Network/Network/Cortex/VirtualHub/NewAzureRmVirtualHubCommand.cs @@ -22,6 +22,7 @@ namespace Microsoft.Azure.Commands.Network using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; + using MNM = Microsoft.Azure.Management.Network.Models; [Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualHub", @@ -97,6 +98,15 @@ public class NewAzureRmVirtualHubCommand : VirtualHubBaseCmdlet [PSArgumentCompleter("Basic", "Standard")] public string Sku { get; set; } + [Parameter( + Mandatory = false, + HelpMessage = "Preferred Routing Gateway to Route On-Prem traffic from VNET")] + [ValidateSet( + MNM.PreferredRoutingGateway.ExpressRoute, + MNM.PreferredRoutingGateway.VpnGateway, + IgnoreCase = true)] + public string PreferredRoutingGateway { get; set; } + [Parameter( Mandatory = false, HelpMessage = "Run cmdlet in the background")] @@ -164,6 +174,15 @@ public override void Execute() virtualHub.Sku = "Standard"; } + if (string.IsNullOrWhiteSpace(this.PreferredRoutingGateway)) + { + virtualHub.PreferredRoutingGateway = "ExpressRoute"; + } + else + { + virtualHub.PreferredRoutingGateway = this.PreferredRoutingGateway; + } + 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 7e85d4aa6c88..5a001900547a 100644 --- a/src/Network/Network/Cortex/VirtualHub/UpdateAzureRmVirtualHubCommand.cs +++ b/src/Network/Network/Cortex/VirtualHub/UpdateAzureRmVirtualHubCommand.cs @@ -103,6 +103,15 @@ public class UpdateAzureRmVirtualHubCommand : VirtualHubBaseCmdlet [PSArgumentCompleter("Basic", "Standard")] public string Sku { get; set; } + [Parameter( + Mandatory = false, + HelpMessage = "Preferred Routing Gateway to Route On-Prem traffic from VNET")] + [ValidateSet( + MNM.PreferredRoutingGateway.ExpressRoute, + MNM.PreferredRoutingGateway.VpnGateway, + IgnoreCase = true)] + public string PreferredRoutingGateway { get; set; } + [Parameter( Mandatory = false, HelpMessage = "Run cmdlet in the background")] @@ -180,6 +189,11 @@ public override void Execute() virtualHubToUpdate.Sku = this.Sku; } + if (!string.IsNullOrWhiteSpace(this.PreferredRoutingGateway)) + { + virtualHubToUpdate.PreferredRoutingGateway = this.PreferredRoutingGateway; + } + //// Update the virtual hub ConfirmAction( Properties.Resources.SettingResourceMessage, diff --git a/src/Network/Network/Models/Cortex/PSVirtualHub.cs b/src/Network/Network/Models/Cortex/PSVirtualHub.cs index a4c4f6bda8fc..094c0b242ccf 100644 --- a/src/Network/Network/Models/Cortex/PSVirtualHub.cs +++ b/src/Network/Network/Models/Cortex/PSVirtualHub.cs @@ -60,5 +60,8 @@ public class PSVirtualHub : PSTopLevelResource [Ps1Xml(Label = "RoutingState", Target = ViewControl.Table)] public string RoutingState { get; set; } + + [Ps1Xml(Label = "Preferred Routing Gateway", Target = ViewControl.Table)] + public string PreferredRoutingGateway { 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 a87d69ea9f4a..8ddaa16302a3 100644 --- a/src/Network/Network/Network.format.ps1xml +++ b/src/Network/Network/Network.format.ps1xml @@ -4295,6 +4295,10 @@ Type + + + PreferredRoutingGateway + ProvisioningState diff --git a/src/Network/Network/help/New-AzVirtualHub.md b/src/Network/Network/help/New-AzVirtualHub.md index d8c67ea6d5bb..747d560e6405 100644 --- a/src/Network/Network/help/New-AzVirtualHub.md +++ b/src/Network/Network/help/New-AzVirtualHub.md @@ -16,16 +16,16 @@ Creates an Azure VirtualHub resource. ``` New-AzVirtualHub -ResourceGroupName -Name -VirtualWan -AddressPrefix -Location [-HubVnetConnection ] - [-RouteTable ] [-Tag ] [-Sku ] [-AsJob] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-RouteTable ] [-Tag ] [-Sku ] [-PreferredRoutingGateway ] + [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByVirtualWanResourceId ``` New-AzVirtualHub -ResourceGroupName -Name -VirtualWanId -AddressPrefix -Location [-HubVnetConnection ] - [-RouteTable ] [-Tag ] [-Sku ] [-AsJob] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-RouteTable ] [-Tag ] [-Sku ] [-PreferredRoutingGateway ] + [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -50,6 +50,7 @@ VirtualNetworkConnections : {} RouteTables : {} Location : West US Sku : Standard +PreferredRoutingGateway : ExpressRoute Type : Microsoft.Network/virtualHubs ProvisioningState : Succeeded ``` @@ -73,6 +74,7 @@ VirtualNetworkConnections : {} RouteTables : {} Location : West US Sku : Standard +PreferredRoutingGateway : ExpressRoute Type : Microsoft.Network/virtualHubs ProvisioningState : Succeeded ``` @@ -101,6 +103,7 @@ VirtualNetworkConnections : {} RouteTables : {} Location : West US Sku : Standard +PreferredRoutingGateway : ExpressRoute Type : Microsoft.Network/virtualHubs ProvisioningState : Succeeded ``` @@ -109,13 +112,37 @@ The above will create a resource group "testRG", a Virtual WAN and a Virtual Hub This example is similar to Example 2, but also attaches a route table to the virtual hub. +### Example 4 + +```powershell +PS C:\> New-AzResourceGroup -Location "West US" -Name "testRG" +PS C:\> $virtualWan = New-AzVirtualWan -ResourceGroupName "testRG" -Name "myVirtualWAN" -Location "West US" +PS C:\> New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.1.0/24" -PreferredRoutingGateway "VpnGateway" + +VirtualWan : /subscriptions/{subscriptionId}resourceGroups/testRG/providers/Microsoft.Network/virtualWans/myVirtualWAN +ResourceGroupName : testRG +Name : westushub +Id : /subscriptions/{subscriptionId}resourceGroups/testRG/providers/Microsoft.Network/virtualHubs/westushub +AddressPrefix : 10.0.1.0/24 +RouteTable : +Location : West US +Sku : Standard +PreferredRoutingGateway : VpnGateway +VirtualNetworkConnections : {} +Location : West US +Type : Microsoft.Network/virtualHubs +ProvisioningState : Succeeded +``` + +The above will create a resource group "testRG", a Virtual WAN and a Virtual Hub in West US in that resource group in Azure. The virtual hub will have preferred routing gateway as VPNGateway. + ## PARAMETERS ### -AddressPrefix The address space string for this virtual hub. ```yaml -Type: String +Type: System.String Parameter Sets: (All) Aliases: @@ -130,7 +157,7 @@ Accept wildcard characters: False Run cmdlet in the background ```yaml -Type: SwitchParameter +Type: System.Management.Automation.SwitchParameter Parameter Sets: (All) Aliases: @@ -145,7 +172,7 @@ Accept wildcard characters: False The credentials, account, tenant, and subscription used for communication with Azure. ```yaml -Type: IAzureContextContainer +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer Parameter Sets: (All) Aliases: AzContext, AzureRmContext, AzureCredential @@ -160,7 +187,7 @@ Accept wildcard characters: False The hub virtual network connections associated with this Virtual Hub. ```yaml -Type: PSHubVirtualNetworkConnection[] +Type: Microsoft.Azure.Commands.Network.Models.PSHubVirtualNetworkConnection[] Parameter Sets: (All) Aliases: @@ -175,7 +202,7 @@ Accept wildcard characters: False location. ```yaml -Type: String +Type: System.String Parameter Sets: (All) Aliases: @@ -190,7 +217,7 @@ Accept wildcard characters: False The resource name. ```yaml -Type: String +Type: System.String Parameter Sets: (All) Aliases: ResourceName, VirtualHubName @@ -201,11 +228,27 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -PreferredRoutingGateway +Preferred Routing Gateway to Route On-Prem traffic from VNET + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: +Accepted values: ExpressRoute, VpnGateway + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ResourceGroupName The resource group name. ```yaml -Type: String +Type: System.String Parameter Sets: (All) Aliases: @@ -220,7 +263,7 @@ Accept wildcard characters: False The route table associated with this Virtual Hub. ```yaml -Type: PSVirtualHubRouteTable +Type: Microsoft.Azure.Commands.Network.Models.PSVirtualHubRouteTable Parameter Sets: (All) Aliases: @@ -235,7 +278,7 @@ Accept wildcard characters: False The sku of the Virtual Hub. ```yaml -Type: String +Type: System.String Parameter Sets: (All) Aliases: @@ -250,7 +293,7 @@ Accept wildcard characters: False A hashtable which represents resource tags. ```yaml -Type: Hashtable +Type: System.Collections.Hashtable Parameter Sets: (All) Aliases: @@ -265,7 +308,7 @@ Accept wildcard characters: False The virtual wan object this hub is linked to. ```yaml -Type: PSVirtualWan +Type: Microsoft.Azure.Commands.Network.Models.PSVirtualWan Parameter Sets: ByVirtualWanObject Aliases: @@ -280,7 +323,7 @@ Accept wildcard characters: False The id of virtual wan object this hub is linked to. ```yaml -Type: String +Type: System.String Parameter Sets: ByVirtualWanResourceId Aliases: @@ -295,7 +338,7 @@ Accept wildcard characters: False Prompts you for confirmation before running the cmdlet. ```yaml -Type: SwitchParameter +Type: System.Management.Automation.SwitchParameter Parameter Sets: (All) Aliases: cf @@ -311,7 +354,7 @@ Shows what would happen if the cmdlet runs. The cmdlet is not run. ```yaml -Type: SwitchParameter +Type: System.Management.Automation.SwitchParameter Parameter Sets: (All) Aliases: wi diff --git a/src/Network/Network/help/Update-AzVirtualHub.md b/src/Network/Network/help/Update-AzVirtualHub.md index 81940e5b7b4c..2d61490b3c7b 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 ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-AsJob] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByVirtualHubResourceId ``` Update-AzVirtualHub -ResourceId [-AddressPrefix ] [-HubVnetConnection ] [-RouteTable ] - [-Tag ] [-Sku ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-AsJob] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### ByVirtualHubObject ``` Update-AzVirtualHub -InputObject [-AddressPrefix ] [-HubVnetConnection ] [-RouteTable ] - [-Tag ] [-Sku ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-Tag ] [-Sku ] [-PreferredRoutingGateway ] [-AsJob] + [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -91,13 +91,38 @@ ProvisioningState : Succeeded The above will create a resource group "testRG", a Virtual WAN and a Virtual Hub in West US in that resource group in Azure. The virtual hub will have the address space "10.0.1.0/24". This example is similar to Example 1, but also attaches a route table to the virtual hub. +### Example 3 + +```powershell +PS C:\> New-AzResourceGroup -Location "West US" -Name "testRG" +PS C:\> $virtualWan = New-AzVirtualWan -ResourceGroupName "testRG" -Name "myVirtualWAN" -Location "West US" +PS C:\> New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.1.0/24" +PS C:\> Update-AzVirtualHub -ResourceGroupName "testRG" -Name "westushub" -PreferredRoutingGateway "VpnGateway" + +VirtualWan : /subscriptions/{subscriptionId}resourceGroups/testRG/providers/Microsoft.Network/virtualWans/myVirtualWAN +ResourceGroupName : testRG +Name : westushub +Id : /subscriptions/{subscriptionId}resourceGroups/testRG/providers/Microsoft.Network/virtualHubs/westushub +AddressPrefix : 10.0.1.0/24 +RouteTable : +Location : West US +Sku : Standard +PreferredRoutingGateway : VpnGateway +VirtualNetworkConnections : {} +Location : West US +Type : Microsoft.Network/virtualHubs +ProvisioningState : Succeeded +``` + +The above will create a resource group "testRG", a Virtual WAN and a Virtual Hub in West US in that resource group in Azure. The virtual hub will have preferred routing gateway as ExpressRoute initially and will then be updated to VpnGateway. + ## PARAMETERS ### -AddressPrefix The address space string for this virtual hub. ```yaml -Type: String +Type: System.String Parameter Sets: (All) Aliases: @@ -112,7 +137,7 @@ Accept wildcard characters: False Run cmdlet in the background ```yaml -Type: SwitchParameter +Type: System.Management.Automation.SwitchParameter Parameter Sets: (All) Aliases: @@ -127,7 +152,7 @@ Accept wildcard characters: False The credentials, account, tenant, and subscription used for communication with Azure. ```yaml -Type: IAzureContextContainer +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer Parameter Sets: (All) Aliases: AzContext, AzureRmContext, AzureCredential @@ -142,7 +167,7 @@ Accept wildcard characters: False The hub virtual network connections associated with this Virtual Hub. ```yaml -Type: PSHubVirtualNetworkConnection[] +Type: Microsoft.Azure.Commands.Network.Models.PSHubVirtualNetworkConnection[] Parameter Sets: (All) Aliases: @@ -157,7 +182,7 @@ Accept wildcard characters: False The Virtual hub object to be modified. ```yaml -Type: PSVirtualHub +Type: Microsoft.Azure.Commands.Network.Models.PSVirtualHub Parameter Sets: ByVirtualHubObject Aliases: VirtualHub @@ -172,7 +197,7 @@ Accept wildcard characters: False The resource name. ```yaml -Type: String +Type: System.String Parameter Sets: ByVirtualHubName Aliases: ResourceName, VirtualHubName @@ -183,11 +208,27 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -PreferredRoutingGateway +Preferred Routing Gateway to Route On-Prem traffic from VNET + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: +Accepted values: ExpressRoute, VpnGateway + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -ResourceGroupName The resource group name. ```yaml -Type: String +Type: System.String Parameter Sets: ByVirtualHubName Aliases: @@ -202,7 +243,7 @@ Accept wildcard characters: False The resource id of the Virtual hub to be modified. ```yaml -Type: String +Type: System.String Parameter Sets: ByVirtualHubResourceId Aliases: VirtualHubId @@ -217,7 +258,7 @@ Accept wildcard characters: False The route table associated with this Virtual Hub. ```yaml -Type: PSVirtualHubRouteTable +Type: Microsoft.Azure.Commands.Network.Models.PSVirtualHubRouteTable Parameter Sets: (All) Aliases: @@ -232,7 +273,7 @@ Accept wildcard characters: False The sku of the Virtual Hub. ```yaml -Type: String +Type: System.String Parameter Sets: (All) Aliases: @@ -247,7 +288,7 @@ Accept wildcard characters: False A hashtable which represents resource tags. ```yaml -Type: Hashtable +Type: System.Collections.Hashtable Parameter Sets: (All) Aliases: @@ -262,7 +303,7 @@ Accept wildcard characters: False Prompts you for confirmation before running the cmdlet. ```yaml -Type: SwitchParameter +Type: System.Management.Automation.SwitchParameter Parameter Sets: (All) Aliases: cf @@ -278,7 +319,7 @@ Shows what would happen if the cmdlet runs. The cmdlet is not run. ```yaml -Type: SwitchParameter +Type: System.Management.Automation.SwitchParameter Parameter Sets: (All) Aliases: wi