Dela via


New-AzVirtualHubVnetConnection

Cmdleten New-AzVirtualHubVnetConnection skapar en HubVirtualNetworkConnection-resurs som peerkopplar ett virtuellt nätverk till Azure Virtual Hub.

Syntax

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

Cmdleten New-AzVirtualHubVnetConnection skapar en HubVirtualNetworkConnection-resurs som peerkopplar ett virtuellt nätverk till Azure Virtual Hub.

Exempel

Exempel 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": []
                            }
                        }

Ovanstående skapar en resursgrupp, Virtual WAN, Virtual Network, Virtual Hub i USA, centrala i den resursgruppen i Azure. Därefter skapas en anslutning till ett virtuellt nätverk som peerkopplar det virtuella nätverket till den virtuella hubben.

Exempel 2

Cmdleten New-AzVirtualHubVnetConnection skapar en HubVirtualNetworkConnection-resurs som peerkopplar ett virtuellt nätverk till Azure Virtual Hub. (automatiskt genererad)

New-AzVirtualHubVnetConnection -EnableInternetSecurity -Name 'testvnetconnection' -ParentResourceName 'westushub' -RemoteVirtualNetwork <PSVirtualNetwork> -ResourceGroupName 'testRG'

Exempel 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

Ovanstående skapar en ny routningskonfiguration och skapar statiska vägar i routningskonfigurationen med nästa hopp som en angiven IP-adress. Den här routningskonfigurationen kan sedan skickas till kommandot New-AzVirtualHubVnetConnection som parametern -RoutingConfiguration.

Parametrar

-AsJob

Kör cmdlet i bakgrunden

Typ:SwitchParameter
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-Confirm

Uppmanar dig att bekräfta innan du kör cmdleten.

Typ:SwitchParameter
Alias:cf
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-DefaultProfile

Autentiseringsuppgifter, konto, klientorganisation och prenumeration som används för kommunikation med Azure.

Typ:IAzureContextContainer
Alias:AzContext, AzureRmContext, AzureCredential
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-EnableInternetSecurity

Aktivera Internetsäkerhet för den här anslutningen

Typ:SwitchParameter
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-EnableInternetSecurityFlag

Aktivera Internetsäkerhet för den här anslutningen

Typ:Nullable<T>[Boolean]
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-Name

Resursnamnet.

Typ:String
Alias:ResourceName, HubVirtualNetworkConnectionName
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-ParentObject

Den överordnade resursen.

Typ:PSVirtualHub
Alias:VirtualHub, ParentVirtualHub
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:True
Godkänn jokertecken:False

-ParentResourceId

Den överordnade resursen.

Typ:String
Alias:VirtualHubId, ParentVirtualHubId
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:True
Godkänn jokertecken:False

-ParentResourceName

Resursgruppens namn.

Typ:String
Alias:VirtualHubName, ParentVirtualHubName
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-RemoteVirtualNetwork

Det virtuella fjärrnätverk som den här virtuella hubbanslutningen är ansluten till.

Typ:PSVirtualNetwork
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-RemoteVirtualNetworkId

Det virtuella fjärrnätverk som den här virtuella hubbanslutningen är ansluten till.

Typ:String
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-ResourceGroupName

Resursgruppens namn.

Typ:String
Position:Named
Standardvärde:None
Obligatorisk:True
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-RoutingConfiguration

Routningskonfiguration för den här anslutningen

Typ:PSRoutingConfiguration
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

-WhatIf

Visar vad som skulle hända om cmdleten kördes. Cmdleten körs inte.

Typ:SwitchParameter
Alias:wi
Position:Named
Standardvärde:None
Obligatorisk:False
Godkänn pipeline-indata:False
Godkänn jokertecken:False

Indata

PSVirtualHub

String

Utdata

PSHubVirtualNetworkConnection