New-AzVHubRoute
Skapar ett VHubRoute-objekt som kan skickas som parameter till kommandot New-AzVHubRouteTable.
Syntax
New-AzVHubRoute
-Destination <String[]>
-DestinationType <String>
-NextHop <String>
-Name <String>
-NextHopType <String>
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
Skapar ett VHubRoute-objekt.
Exempel
Exempel 1
$rgName = "testRg"
$firewallName = "testFirewall"
$firewall = Get-AzFirewall -Name $firewallName -ResourceGroupName $rgName
New-AzVHubRoute -Name "private-traffic" -Destination @("10.30.0.0/16", "10.40.0.0/16") -DestinationType "CIDR" -NextHop $firewall.Id -NextHopType "ResourceId"
Name : private-traffic
DestinationType : CIDR
Destinations : {10.30.0.0/16, 10.40.0.0/16}
NextHopType : ResourceId
NextHop : /subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/azureFirewalls/testFirewall
Kommandot ovan skapar ett VHubRoute-objekt med nextHop som den angivna brandväggen som sedan kan läggas till i en VHubRouteTable-resurs.
Exempel 2
$rgName = "testRg"
$hubName = "testHub"
$hubVnetConnName = "testHubVnetConn"
$hubVnetConnection = Get-AzVirtualHubVnetConnection -Name $hubVnetConnName -ParentResourceName $hubName -ResourceGroupName $rgName
New-AzVHubRoute -Name "nva-traffic" -Destination @("10.20.0.0/16", "10.50.0.0/16") -DestinationType "CIDR" -NextHop $hubVnetConnection.Id -NextHopType "ResourceId"
Name : private-traffic
DestinationType : CIDR
Destinations : {10.30.0.0/16, 10.40.0.0/16}
NextHopType : ResourceId
NextHop : /subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/testHub/hubVirtualNetworkConnections/testHubVnetConn
Kommandot ovan skapar ett VHubRoute-objekt med nextHop som angivet hubVnetConnection som sedan kan läggas till i en VHubRouteTable-resurs.
Exempel 3
$hub = Get-AzVirtualHub -ResourceGroupName "rgname" -Name "virtual-hub-name"
$hubVnetConn = Get-AzVirtualHubVnetConnection -ParentObject $hub -Name "connection-name"
$hubVnetConn
Name : conn_2
Id : /subscriptions/{subscriptionID}/resourceGroups/{rgname}/providers/Microsoft.Network/virtualHubs/{virtual-hub-name}/hubVirtualNetworkConnections/conn_2
RemoteVirtualNetwork : /subscriptions/{subscriptionID}/resourceGroups/{rgname}/providers/Microsoft.Network/virtualNetworks/rVnet_2
EnableInternetSecurity : True
ProvisioningState : Succeeded
RoutingConfiguration : {
"AssociatedRouteTable": {
"Id": "/subscriptions/{subscriptionID}/resourceGroups/{rgname}/providers/Microsoft.Network/virtualHubs/{virtual-hub-name}/hubRouteTables/defaultRouteTable"
},
"PropagatedRouteTables": {
"Labels": [
"default"
],
"Ids": [
{
"Id":
"/subscriptions/{subscriptionID}/resourceGroups/{rgname}/providers/Microsoft.Network/virtualHubs/{virtual-hub-name}/hubRouteTables/defaultRouteTable"
}
]
},
"VnetRoutes": {
"StaticRoutes": []
}
}
$staticRoute1 = New-AzStaticRoute -Name "static_route1" -AddressPrefix @("10.2.1.0/24", "10.2.3.0/24") -NextHopIpAddress "10.2.0.5"
$routingConfig = $hubVnetConn.RoutingConfiguration
$routingConfig.VnetRoutes.StaticRoutes = @($staticRoute1)
$routingConfig
AssociatedRouteTable : Microsoft.Azure.Commands.Network.Models.PSResourceId
PropagatedRouteTables : {
"Labels": [
"default"
],
"Ids": [
{
"Id":
"/subscriptions/{subscriptionID}/resourceGroups/{rgname}/providers/Microsoft.Network/virtualHubs/rTestHub1/hubRouteTables/defaultRouteTable"
}
]
}
VnetRoutes : {
"StaticRoutes": [
{
"Name": "static_route1",
"AddressPrefixes": [
"10.2.1.0/24",
"10.2.3.0/24"
],
"NextHopIpAddress": "10.2.0.5"
}
]
}
Update-AzVirtualHubVnetConnection -InputObject $hubVnetConn -RoutingConfiguration $routingConfig
Ovanstående kommandon hämtar RoutingConfiguration för en redan befintlig AzVHubRoute och lägger sedan till en statisk väg på anslutningen. Om du vill skapa en ny anslutning med den statiska vägen i den kan du också läsa Exempel 1 här.
Parametrar
-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 |
-Destination
Lista över destinationer.
Typ: | String[] |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-DestinationType
Typ av mål.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-Name
Routningsnamnet.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-NextHop
Nästa hopp.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-NextHopType
Typen Nästa hopp.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
Indata
Utdata
Relaterade länkar
Azure PowerShell