分享方式:


虛擬網路中的輸出計量

適用於: Windows Server 2022、Windows Server 2019、Windows Server 2016

雲端網路獲利的基本層面是能夠透過網路頻寬使用率來計費。 輸出資料會根據指定計費週期中透過網際網路移出資料中心的總數據量收費。

Windows Server 2019 中 SDN 網路流量的輸出計量可讓您提供輸出資料傳輸的使用計量。 離開每個虛擬網路但保留在資料中心內的網路流量可以分開追蹤,以便從計費計算中排除。 繫結至目的地 IP 位址的封包未包含在其中一個未計費的位址範圍中,會追蹤為計費的輸出資料傳輸。

虛擬網路未計費的位址範圍 (允許 IP 範圍清單)

您可以在現有虛擬網路的 UnbilledAddressRanges 屬性下找到未計費的位址範圍。 根據預設,不會新增任何位址範圍。

import-module NetworkController
$uri = "https://sdn.contoso.com"

(Get-NetworkControllerVirtualNetwork -ConnectionURI $URI -ResourceId "VNet1").properties

您的輸出看起來會像這樣:

 AddressSpace           : Microsoft.Windows.NetworkController.AddressSpace
 DhcpOptions            :
 UnbilledAddressRanges  :
 ConfigurationState     :
 ProvisioningState      : Succeeded
 Subnets                : {21e71701-9f59-4ee5-b798-2a9d8c2762f0, 5f4758ef-9f96-40ca-a389-35c414e996cc,
                      29fe67b8-6f7b-486c-973b-8b9b987ec8b3}
 VirtualNetworkPeerings :
 EncryptionCredential   :
 LogicalNetwork         : Microsoft.Windows.NetworkController.LogicalNetwork

範例:管理虛擬網路的未計費位址範圍

您可以藉由設定虛擬網路的 UnbilledAddressRange 屬性,來管理要從計費輸出計量中排除的 IP 子網路首碼集。 虛擬網路上網路介面傳送且目的地 IP 位址符合其中一個前置詞的任何流量,都不會包含在 BilledEgressBytes 屬性中。

  1. 更新 UnbilledAddressRanges 屬性,以包含不會收取存取費用的子網路。

    $vnet = Get-NetworkControllerVirtualNetwork -ConnectionUri $uri -ResourceID "VNet1"
    $vnet.Properties.UnbilledAddressRanges = "10.10.2.0/24,10.10.3.0/24"
    

    提示

    如果新增多個 IP 子網路,請使用每個 IP 子網路之間的逗號。 請勿在逗號前後包含任何空格。

  2. 使用已修改的 UnbilledAddressRanges 屬性更新虛擬網路資源。

    New-NetworkControllerVirtualNetwork -ConnectionUri $uri -ResourceId "VNet1" -Properties $unbilled.Properties -PassInnerException
    

    您的輸出看起來會像這樣:

       Confirm
       Performing the operation 'New-NetworkControllerVirtualNetwork' on entities of type
       'Microsoft.Windows.NetworkController.VirtualNetwork' via
       'https://sdn.contoso.com/networking/v3/virtualNetworks/VNet1'. Are you sure you want to continue?
       [Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y
    
    
       Tags             :
       ResourceRef      : /virtualNetworks/VNet1
       InstanceId       : 29654b0b-9091-4bed-ab01-e172225dc02d
       Etag             : W/"6970d0a3-3444-41d7-bbe4-36327968d853"
       ResourceMetadata :
       ResourceId       : VNet1
       Properties       : Microsoft.Windows.NetworkController.VirtualNetworkProperties
    
  3. 檢查虛擬網路以查看已設定的 UnbilledAddressRanges

    (Get-NetworkControllerVirtualNetwork -ConnectionUri $uri -ResourceID "VNet1").properties
    

    您的輸出現在看起來會像這樣:

    AddressSpace           : Microsoft.Windows.NetworkController.AddressSpace
    DhcpOptions            :
    UnbilledAddressRanges  : 10.10.2.0/24,192.168.2.0/24
    ConfigurationState     :
    ProvisioningState      : Succeeded
    Subnets                : {21e71701-9f59-4ee5-b798-2a9d8c2762f0, 5f4758ef-9f96-40ca-a389-35c414e996cc,
                         29fe67b8-6f7b-486c-973b-8b9b987ec8b3}
    VirtualNetworkPeerings :
    EncryptionCredential   :
    LogicalNetwork         : Microsoft.Windows.NetworkController.LogicalNetwork
    

檢查虛擬網路未計費的輸出使用量

設定 UnbilledAddressRanges 屬性之後,您可以檢查虛擬網路內每個子網路的計費和未計費輸出使用量。 輸出流量會每隔四分鐘更新一次,其中包含計費和未計費範圍的位元組總數。

每個虛擬子網路都有下列屬性:

  • UnbilledEgressBytes 會顯示連線至此虛擬子網路的網路介面所傳送的未計費位元組數目。 未計費的位元組是傳送至父虛擬網路之 UnbilledAddressRanges 屬性之位址範圍的位元組。

  • BilledEgressBytes 會顯示連線至此虛擬子網路的網路介面所傳送的計費位元組數目。 計費位元組是傳送至父虛擬網路之 UnbilledAddressRanges 屬性之位址範圍的位元組。

使用下列範例來查詢輸出使用量:

(Get-NetworkControllerVirtualNetwork -ConnectionURI $URI -ResourceId "VNet1").properties.subnets.properties | ft AddressPrefix,BilledEgressBytes,UnbilledEgressBytes

您的輸出看起來會像這樣:

AddressPrefix BilledEgressBytes UnbilledEgressBytes
------------- ----------------- -------------------
10.0.255.8/29          16827067                   0
10.0.2.0/24           781733019                   0
10.0.4.0/24                   0                   0