New-AzVirtualHubVnetConnection
New-AzVirtualHubVnetConnection Cmdlet 會建立將 虛擬網絡 對等互連至 Azure 虛擬中樞的 HubVirtualNetworkConnection 資源。
語法
New-AzVirtualHubVnetConnection
-ResourceGroupName <String>
-ParentResourceName <String>
-Name <String>
-RemoteVirtualNetwork <PSVirtualNetwork>
[-EnableInternetSecurity]
[-EnableInternetSecurityFlag <Boolean>]
[-RoutingConfiguration <PSRoutingConfiguration>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzVirtualHubVnetConnection
-ResourceGroupName <String>
-ParentResourceName <String>
-Name <String>
-RemoteVirtualNetworkId <String>
[-EnableInternetSecurity]
[-EnableInternetSecurityFlag <Boolean>]
[-RoutingConfiguration <PSRoutingConfiguration>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzVirtualHubVnetConnection
-ParentObject <PSVirtualHub>
-Name <String>
-RemoteVirtualNetwork <PSVirtualNetwork>
[-EnableInternetSecurity]
[-EnableInternetSecurityFlag <Boolean>]
[-RoutingConfiguration <PSRoutingConfiguration>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzVirtualHubVnetConnection
-ParentObject <PSVirtualHub>
-Name <String>
-RemoteVirtualNetworkId <String>
[-EnableInternetSecurity]
[-EnableInternetSecurityFlag <Boolean>]
[-RoutingConfiguration <PSRoutingConfiguration>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzVirtualHubVnetConnection
-ParentResourceId <String>
-Name <String>
-RemoteVirtualNetwork <PSVirtualNetwork>
[-EnableInternetSecurity]
[-EnableInternetSecurityFlag <Boolean>]
[-RoutingConfiguration <PSRoutingConfiguration>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzVirtualHubVnetConnection
-ParentResourceId <String>
-Name <String>
-RemoteVirtualNetworkId <String>
[-EnableInternetSecurity]
[-EnableInternetSecurityFlag <Boolean>]
[-RoutingConfiguration <PSRoutingConfiguration>]
[-AsJob]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
New-AzVirtualHubVnetConnection Cmdlet 會建立將 虛擬網絡 對等互連至 Azure 虛擬中樞的 HubVirtualNetworkConnection 資源。
範例
範例 1
New-AzResourceGroup -Location "West US" -Name "testRG"
$frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$backendSubnet = New-AzVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix "10.0.2.0/24"
$remoteVirtualNetwork = New-AzVirtualNetwork -Name "MyVirtualNetwork" -ResourceGroupName "testRG" -Location "West US" -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet,$backendSubnet
$virtualWan = New-AzVirtualWan -ResourceGroupName "testRG" -Name "myVirtualWAN" -Location "West US"
New-AzVirtualHub -VirtualWan $virtualWan -ResourceGroupName "testRG" -Name "westushub" -AddressPrefix "10.0.1.0/24"
New-AzVirtualHubVnetConnection -ResourceGroupName "testRG" -VirtualHubName "westushub" -Name "testvnetconnection" -RemoteVirtualNetwork $remoteVirtualNetwork
Name : testvnetconnection
Id : /subscriptions/{subscriptionId}/resourceGroups/testRG/providers/Microsoft.Network/virtualHubs/westushub/hubVirtualNetworkConnections/testvnetconnection
RemoteVirtualNetwork : /subscriptions/{subscriptionId}/resourceGroups/testRG/providers/Microsoft.Network/virtualNetworks/MyVirtualNetwork
EnableInternetSecurity : False
ProvisioningState : Succeeded
RoutingConfiguration : {
"AssociatedRouteTable": {
"Id": "/subscriptions/{subscriptionId}/resourceGroups/testRG/providers/Microsoft.Network/virtualHubs/westushub/hubRouteTables/defaultRouteTable"
},
"PropagatedRouteTables": {
"Labels": [],
"Ids": [
{
"Id": "/subscriptions/{subscriptionId}/resourceGroups/testRG/providers/Microsoft.Network/virtualHubs/westushub/hubRouteTables/defaultRouteTable"
}
]
},
"VnetRoutes": {
"StaticRoutes": []
}
}
上述會建立資源群組、虛擬 WAN、虛擬網絡、位於美國中部的虛擬中樞,並在 Azure 中的該資源群組中建立虛擬中樞。 之後,將會建立 虛擬網絡 連線,以將 虛擬網絡 對等互連至虛擬中樞。
範例 2
New-AzVirtualHubVnetConnection Cmdlet 會建立將 虛擬網絡 對等互連至 Azure 虛擬中樞的 HubVirtualNetworkConnection 資源。 ( 自動產生 )
New-AzVirtualHubVnetConnection -EnableInternetSecurity -Name 'testvnetconnection' -ParentResourceName 'westushub' -RemoteVirtualNetwork <PSVirtualNetwork> -ResourceGroupName 'testRG'
範例 3
$rgName = "testRg"
$virtualHubName = "testHub"
$frontendSubnet = New-AzVirtualNetworkSubnetConfig -Name frontendSubnet -AddressPrefix "10.0.1.0/24"
$backendSubnet = New-AzVirtualNetworkSubnetConfig -Name backendSubnet -AddressPrefix "10.0.2.0/24"
$remoteVirtualNetwork = New-AzVirtualNetwork -Name "MyVirtualNetwork" -ResourceGroupName $rgName -Location "West US" -AddressPrefix "10.0.0.0/16" -Subnet $frontendSubnet,$backendSubnet
$rt1 = Get-AzVHubRouteTable -ResourceGroupName $rgName -VirtualHubName $virtualHubName -Name "defaultRouteTable"
$rt2 = Get-AzVHubRouteTable -ResourceGroupName $rgName -VirtualHubName $virtualHubName -Name "noneRouteTable"
$route1 = New-AzStaticRoute -Name "route1" -AddressPrefix @("10.20.0.0/16", "10.30.0.0/16")-NextHopIpAddress "10.90.0.5"
$routingconfig = New-AzRoutingConfiguration -AssociatedRouteTable $rt1.Id -Label @("testLabel") -Id @($rt2.Id) -StaticRoute @($route1)
AssociatedRouteTable : "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/testHub/hubRouteTables/defaultRouteTable"
PropagatedRouteTables : {
"Labels": [
"testLabel"
],
"Ids": [
{
"Id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/testHub/hubRouteTables/noneRouteTable"
}
]
}
VnetRoutes : {
"StaticRoutes": [
{
"Name": "route1",
"AddressPrefixes": [
"10.20.0.0/16",
"10.30.0.0/16"
],
"NextHopIpAddress": "10.90.0.5"
}
]
}
New-AzVirtualHubVnetConnection -ResourceGroupName $rgName -VirtualHubName $virtualHubName -Name "testvnetconnection" -RemoteVirtualNetwork $remoteVirtualNetwork -RoutingConfiguration $routingconfig
上述會建立新的路由組態,並在路由設定中建立靜態路由,並將下一個躍點作為指定的IP位址。 接著,此路由設定可以傳遞至 New-AzVirtualHubVnetConnection 命令做為參數 -RoutingConfiguration。
參數
-AsJob
在背景執行 Cmdlet
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Confirm
執行 Cmdlet 之前先提示您確認。
類型: | SwitchParameter |
別名: | cf |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-DefaultProfile
用於與 Azure 通訊的認證、帳戶、租用戶和訂用帳戶。
類型: | IAzureContextContainer |
別名: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-EnableInternetSecurity
啟用此連線的因特網安全性
類型: | SwitchParameter |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-EnableInternetSecurityFlag
啟用此連線的因特網安全性
類型: | Nullable<T>[Boolean] |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-Name
資源名稱。
類型: | String |
別名: | ResourceName, HubVirtualNetworkConnectionName |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-ParentObject
父資源。
類型: | PSVirtualHub |
別名: | VirtualHub, ParentVirtualHub |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-ParentResourceId
父資源。
類型: | String |
別名: | VirtualHubId, ParentVirtualHubId |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | True |
接受萬用字元: | False |
-ParentResourceName
資源組名。
類型: | String |
別名: | VirtualHubName, ParentVirtualHubName |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-RemoteVirtualNetwork
此中樞虛擬網路連線連接的遠端虛擬網路。
類型: | PSVirtualNetwork |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-RemoteVirtualNetworkId
此中樞虛擬網路連線連接的遠端虛擬網路。
類型: | String |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-ResourceGroupName
資源組名。
類型: | String |
Position: | Named |
預設值: | None |
必要: | True |
接受管線輸入: | False |
接受萬用字元: | False |
-RoutingConfiguration
此連線的路由設定
類型: | PSRoutingConfiguration |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |
-WhatIf
顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。
類型: | SwitchParameter |
別名: | wi |
Position: | Named |
預設值: | None |
必要: | False |
接受管線輸入: | False |
接受萬用字元: | False |