Set-AzRouteConfig
語法
Default (預設值)
Set-AzRouteConfig
-RouteTable <PSRouteTable>
[-Name <String>]
[-AddressPrefix <String>]
[-NextHopType <String>]
[-NextHopIpAddress <String>]
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Set-AzRouteConfig Cmdlet 會更新路由表的路由設定。
範例
範例 1:修改路由
Get-AzRouteTable -ResourceGroupName "ResourceGroup11" -Name "RouteTable01" | Set-AzRouteConfig -Name "Route02" -AddressPrefix 10.4.0.0/16 -NextHopType VnetLocal | Set-AzRouteTable
Name : Routetable01
ResourceGroupName : ResourceGroup11
Location : eastus
Id : /subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/ResourceGroup11/providers/Microsoft.Networ
k/routeTables/RouteTable01
Etag : W/"58c2922e-9efe-4554-a457-956ef44bc718"
ProvisioningState : Succeeded
Tags :
Routes : [
{
"Name": "Route07",
"Etag": "W/\"58c2922e-9efe-4554-a457-956ef44bc718\"",
"Id": "/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/ResourceGroup11/providers/Micro
soft.Network/routeTables/Routetable01/routes/Route07",
"AddressPrefix": "10.1.0.0/16",
"NextHopType": "VnetLocal",
"NextHopIpAddress": null,
"ProvisioningState": "Succeeded"
},
{
"Name": "route02",
"Etag": "W/\"58c2922e-9efe-4554-a457-956ef44bc718\"",
"Id": "/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/ResourceGroup11/providers/Micro
soft.Network/routeTables/routetable01/routes/route02",
"AddressPrefix": "10.4.0.0/16",
"NextHopType": "VnetLocal",
"NextHopIpAddress": null,
"ProvisioningState": "Succeeded"
}
]
Subnets : []
此命令會使用 Get-AzRouteTable Cmdlet 取得名為 RouteTable01 的路由表。
命令會使用管線運算子將該資料表傳遞至目前的 Cmdlet。
目前的 Cmdlet 會修改名為 Route02 的路由,然後將結果傳遞至 Set-AzRouteTable Cmdlet,以更新資料表以反映您的變更。
範例 2:使用服務標籤修改路由 (公開預覽版)
Set-AzRouteConfig -Name "Route02" -AddressPrefix "AppService" -NextHopType "VirtualAppliance" -NextHopIpAddress "10.0.2.4"
此命令修改名為 Route02 的路由,提供服務標籤作為 AddressPrefix 參數。
參數
-AddressPrefix
以無類別網域間路由 (CIDR) 格式指定路由套用的目的地。 您也可以在這裡指定服務標籤 (此功能為公開預覽版)。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-Confirm
在執行 Cmdlet 之前,提示您進行確認。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-DefaultProfile
用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Name
指定此 Cmdlet 修改的路由名稱。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-NextHopIpAddress
指定您新增至 Azure 虛擬網路之虛擬設備的 IP 位址。
此路由將資料包轉發到該地址。
只有在您為 NextHopType 參數指定 VirtualAppliance 值時,才指定此參數。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-NextHopType
指定此路由如何轉送封包。
此參數可接受的值為:
- 網際網路。
Azure 所提供的預設網際網路閘道。
- 沒有。
如果指定此值,則路由不會轉送資料包。
- VirtualAppliance 的 VirtualAppliance 中。
您新增至 Azure 虛擬網路的虛擬設備。
- VirtualNetworkGateway 的 VirtualNetworkGateway 中。
Azure伺服器對伺服器虛擬私人網路閘道。
- VnetLocal的。
本機虛擬網路。
如果您在相同的虛擬網路中有兩個子網 10.1.0.0/16 和 10.2.0.0/16,請為每個子網選取 VnetLocal 值,以轉送至另一個子網。
參數屬性
| 類型: | String
|
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-RouteTable
指定與此路由相關聯的路由表。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-WhatIf
顯示 Cmdlet 執行時會發生什麼事。 指令未執行。
參數屬性
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 Cmdlet 支援常見參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸出