跳轉到

使用 API 在 MCR 與 Microsoft Azure 之間建立 VXC

本主題說明如何使用 API 從 MCR 建立到 Microsoft Azure ExpressRoute 的 VXC,包括如何查詢 Azure 互連位置並訂購 VXCs。

MCR 到 Azure 的部署包含下列工作:

  1. Set up an ExpressRoute circuit in the Azure console (在 Azure 主控台中設定 ExpressRoute 電路)

    部署後,您會取得一組服務金鑰。當您驗證服務金鑰時,系統會提供主要與次要連接埠,您可以選擇用於連線的連接埠。您可以第二次使用該金鑰,為未使用的連接埠建立另一個連線。

    如需詳細資訊,請參閱 Microsoft 說明主題 Tutorial: Create and modify an ExpressRoute circuit

  2. With the service key, create and deploy your VXC (使用服務金鑰建立並部署您的 VXC)

    作為 VXC 設定的一部分,您可以選擇 Peering 類型。

    Peering 類型可以是 private 或 Microsoft。

    已定義的 Peering 類型會自動設定 Peering,並在 Azure 與 Megaport 兩端配對到相符的對等端,讓系統以已知可運作的設定部署。部署完成後,您可以修改設定。

開始之前,請先取得有效的存取權杖。如需詳細資訊,請參閱 建立 API 金鑰

驗證服務金鑰

當您使用 API 驗證 Azure 服務金鑰時,回應會包含關聯連接埠與對等端的 ExpressRoute 詳細資料。您需要連接埠詳細資料來建立 VXCs。

在 Postman 集合中驗證服務金鑰的方法

  1. 在 Postman 的左側導覽中展開 Cloud Connectivity > MCR > Azure (雲端連線 > MCR > Azure),然後選取 GET Look Up Azure Service Key (GET 查詢 Azure 服務金鑰)

  2. 將服務金鑰新增到端點。

  3. 按一下 Send (傳送) 以向 API 伺服器發出 GET 要求。

    GET {baseUrl}/v2/secure/azure/{service_key}
    

以下是新金鑰的範例回應(未設定 VXCs):

{
    "message": "Successful lookup",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "managed": false,
        "connectType": "AZURE",
        "resource_type": "csp_connection",
        "bandwidth": 200,
        "service_key": "3e2480b2-b4d5-424b-976a-7b0de65a1b62",
        "vlan": 3289,
        "megaports": [
            {
                "portSpeed": 10000,
                "name": "Washington DC Primary",
                "state": "VA",
                "description": "Azure ExpressRoute at Equinix DC2/6",
                "productUid": "a7ae8a35-433e-44aa-87cb-a1b7995ab008",
                "nServiceId": 32832,
                "companyUid": "c40de5ed-4707-4471-a78c-69436de2c505",
                "country": "USA",
                "vxc": null,
                "port": 14570,
                "companyName": "Azure ExpressRoute",
                "locationId": 67,
                "productId": 14570,
                "type": "primary",
                "companyId": 1475
            },
            {
                "portSpeed": 10000,
                "name": "Washington DC Secondary",
                "state": "VA",
                "description": "Azure ExpressRoute at Equinix DC2/6",
                "productUid": "07ab0ee6-7f77-41ac-bbe6-335e3ee6d182",
                "nServiceId": 36431,
                "companyUid": "c40de5ed-4707-4471-a78c-69436de2c505",
                "country": "USA",
                "vxc": null,
                "port": 16108,
                "companyName": "Azure ExpressRoute",
                "locationId": 67,
                "productId": 16108,
                "type": "secondary",
                "companyId": 1475
            }
        ],
        "peers": []
    }
}

如需有關每個回應欄位的詳細資訊,請參閱Azure Service Key 回應欄位

訂購具有 Peering 選項的 VXC

利用服務金鑰提供的詳細資訊,建立一條 VXC 連接至主要通訊埠,並再建立一條 VXC 連接至次要通訊埠。請確保您所選擇的 MCR 位於與服務金鑰查詢結果中的 Azure 通訊埠相同的區域。

如果您在 API 請求中指定 VXC 的 peering 類型,Megaport 會於 MCR 及 Azure 端自動設置 IP 位址與 BGP 詳細資料,以確保 BGP 設定正常運作。

如需指定 peering 類型,請在 partnerConfig 區段的 peers 陣列中新增 peering 類型。如果 peers 陣列不存在,則從 Azure 取得 peers。於建立 VXC 時若未指定 peers,且 Azure 也沒有 peers(新服務金鑰通常如此),則不會自動設定 MCR peering。

MCR 會為每個已設定的 peering 類型建立一個 VLAN。如果同時指定 private 及 Microsoft peering 選項,MCR 將會設定兩個內層 VLAN。

備註

peering 類型會被記錄且無法變更,若金鑰曾經被使用過。

建立 VXC

  1. 使用 POST Create VXC to Azure (v3) 端點建立請求:

    POST {baseUrl}/v3/networkdesign/buy
    

    提示

    若需在下單之前測試您的請求,可使用: POST {baseUrl}/v3/networkdesign/validate

  2. 於請求內容更新 productUid(即 MCR 的產品識別碼)、VXC 的名稱、Azure 通訊埠的 productUid,以及服務金鑰。請加入適當的 peering 選項。最大速度(rateLimit)由服務金鑰回應中的頻寬值定義,本例中為 200。

    Azure VLAN(若有指定)為 Q-in-Q 的外層標籤 VLAN。若未指定 VLAN,系統將自動佈建。

若要使用具有 private peering 選項的 Azure 金鑰,請使用此範本:

 [
     {
        "productUid": "{{mcrid}}",
        "associatedVxcs": [
            {
                "productName": "Azure Primary VXC",
                "rateLimit": 200,
                "term": 12,
                "shutdown": false,
                "promoCode": "promox3mnthfree2",
                "aEnd": {
                    "vlan": 0
                },
                "bEnd": {
                    "productUid": "{{azurepuid}}",
                    "vlan": "{{azurevlan}}",
                    "partnerConfig" : {
                        "connectType": "AZURE",
                        "serviceKey": "{{azurekey}}",
                        "peers": [{"type": "private"}]
                    }
                }
            }
        ]
    }
]

如需設定 Microsoft peering,peers 請使用此行:

          "peers":[{"type":"microsoft"}]

如需同時設定 Microsoft 與 private peering,請使用此行:

          "peers":[{"type":"microsoft"}, {"type": "private"}]

建立主要 Azure 通訊埠的 VXC 後,請再建立一條 VXC 連接至次要 Azure 通訊埠的 productUid(請變更 productNamebEnd: productUid)。

設定回應

當您使用 peering 建立 VXC 後,另一次服務金鑰驗證請求會顯示完整的設定內容。

{
    "message": "Successful lookup",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
        "managed": true,
        "connectType": "AZURE",
        "resource_type": "csp_connection",
        "bandwidth": 200,
        "service_key": "3e2480b2-b4d5-424b-976a-7b0de65a1b62",
        "vlan": 3289,
        "megaports": [
            {
                "portSpeed": 10000,
                "name": "Washington DC Primary",
                "state": "VA",
                "description": "Azure ExpressRoute at Equinix DC2/6",
                "productUid": "a7ae8a35-433e-44aa-87cb-a1b7995ab008",
                "nServiceId": 32832,
                "companyUid": "c40de5ed-4707-4471-a78c-69436de2c505",
                "country": "USA",
                "vxc": 60574,
                "port": 14570,
                "companyName": "Azure ExpressRoute",
                "locationId": 67,
                "productId": 14570,
                "type": "primary",
                "companyId": 1475
            },
            {
                "portSpeed": 10000,
                "name": "Washington DC Secondary",
                "state": "VA",
                "description": "Azure ExpressRoute at Equinix DC2/6",
                "productUid": "07ab0ee6-7f77-41ac-bbe6-335e3ee6d182",
                "nServiceId": 36431,
                "companyUid": "c40de5ed-4707-4471-a78c-69436de2c505",
                "country": "USA",
                "vxc": 60575,
                "port": 16108,
                "companyName": "Azure ExpressRoute",
                "locationId": 67,
                "productId": 16108,
                "type": "secondary",
                "companyId": 1475
            }
        ],
        "peers": [
            {
                "peer_asn": 133937,
                "shared_key": null,
                "primary_subnet": "169.254.167.176/30",
                "secondary_subnet": "169.254.167.180/30",
                "vlan": 100,
                "type": "private"
            },
            {
                "peer_asn": 133937,
                "shared_key": null,
                "prefixes": "117.18.81.116/30,117.18.81.120/30",
                "primary_subnet": "117.18.81.116/30",
                "secondary_subnet": "117.18.81.120/30",
                "vlan": 200,
                "type": "microsoft"
            }
        ]
    }
}