New-AzVirtualHub
Creates an Azure VirtualHub resource.
Note
This is the previous version of our documentation. Please consult the most recent version for up-to-date information.
Syntax
New-AzVirtualHub
-ResourceGroupName <String>
-Name <String>
-VirtualWan <PSVirtualWan>
-AddressPrefix <String>
-Location <String>
[-HubVnetConnection <PSHubVirtualNetworkConnection[]>]
[-RouteTable <PSVirtualHubRouteTable[]>]
[-Tag <Hashtable>]
[-Sku <String>]
[-PreferredRoutingGateway <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzVirtualHub
-ResourceGroupName <String>
-Name <String>
-VirtualWanId <String>
-AddressPrefix <String>
-Location <String>
[-HubVnetConnection <PSHubVirtualNetworkConnection[]>]
[-RouteTable <PSVirtualHubRouteTable[]>]
[-Tag <Hashtable>]
[-Sku <String>]
[-PreferredRoutingGateway <String>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Creates an Azure VirtualHub resource.
Examples
Example 1
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"
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 :
VirtualNetworkConnections : {}
RouteTables : {}
Location : West US
Sku : Standard
PreferredRoutingGateway : ExpressRoute
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 the address space "10.0.1.0/24".
Example 2
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 -VirtualWanId $virtualWan.Id -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.1.0/24" -Location "West US"
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 :
VirtualNetworkConnections : {}
RouteTables : {}
Location : West US
Sku : Standard
PreferredRoutingGateway : ExpressRoute
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 the address space "10.0.1.0/24".
This example is similar to Example 1, but uses a resource Id to reference the Virtual WAN that is required to create the virtual Hub.
Example 3
PS C:\> New-AzResourceGroup -Location "West US" -Name "testRG"
PS C:\> $virtualWan = New-AzVirtualWan -ResourceGroupName "testRG" -Name "myVirtualWAN" -Location "West US"
PS C:\> $route1 = New-AzVirtualHubRoute -AddressPrefix @("10.0.0.0/16", "11.0.0.0/16") -NextHopIpAddress "12.0.0.5"
PS C:\> $route2 = New-AzVirtualHubRoute -AddressPrefix @("13.0.0.0/16") -NextHopIpAddress "14.0.0.5"
PS C:\> $routeTable = New-AzVirtualHubRouteTable -Route @($route1, $route2)
PS C:\> New-AzVirtualHub -VirtualWanId $virtualWan.Id -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.1.0/24" -RouteTable $routeTable
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 : Microsoft.Azure.Commands.Network.Models.PSVirtualHubRouteTable
VirtualNetworkConnections : {}
RouteTables : {}
Location : West US
Sku : Standard
PreferredRoutingGateway : ExpressRoute
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 the address space "10.0.1.0/24" and a route table attached.
This example is similar to Example 2, but also attaches a route table to the virtual hub.
Example 4
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
The address space string for this virtual hub.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Run cmdlet in the background
| Type: | SwitchParameter |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
| Type: | SwitchParameter |
| Aliases: | cf |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The credentials, account, tenant, and subscription used for communication with Azure.
| Type: | IAzureContextContainer |
| Aliases: | AzContext, AzureRmContext, AzureCredential |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The hub virtual network connections associated with this Virtual Hub.
| Type: | PSHubVirtualNetworkConnection[] |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
location.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The resource name.
| Type: | String |
| Aliases: | ResourceName, VirtualHubName |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
Preferred Routing Gateway to Route On-Prem traffic from VNET
| Type: | String |
| Accepted values: | ExpressRoute, VpnGateway |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The resource group name.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The route table associated with this Virtual Hub.
| Type: | PSVirtualHubRouteTable |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The sku of the Virtual Hub.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
A hashtable which represents resource tags.
| Type: | Hashtable |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |
The virtual wan object this hub is linked to.
| Type: | PSVirtualWan |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
The id of virtual wan object this hub is linked to.
| Type: | String |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | True |
| Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
| Type: | SwitchParameter |
| Aliases: | wi |
| Position: | Named |
| Default value: | None |
| Accept pipeline input: | False |
| Accept wildcard characters: | False |