跳轉到

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

本主題說明使用 API 從 Port 建立至 Microsoft Azure ExpressRoute 的 VXC 的流程,其中包括如何查詢 Azure 連接埠位置並訂購 VXC。

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

  1. 在 Azure 主控台中設定 ExpressRoute 電路

    部署完成後,你會取得一組服務金鑰。該服務金鑰會連結到 Azure 中指派的連接埠。當你驗證服務金鑰時,回應會顯示在 Azure 中指派的主要與次要連接埠。你可以將這個服務金鑰使用兩次:第一次連線到主要,第二次再建立到次要連接埠的另一個連線。
    如需詳細資訊,請參閱 Microsoft 說明主題 Tutorial: Create and modify an ExpressRoute circuit

  2. 使用服務金鑰,從 Megaport Portal 建立並部署你的 VXC

    此步驟使用 API – 其他步驟則在 Azure 環境中,屬於 Megaport 之外的作業。

  3. 在已將 VXC 部署到你的電路後,於 Azure 入口網站中設定 Peering

    Peering 資訊會在主要與次要電路之間共用,指派給對等端的內部 VLAN 亦同。
    如需詳細資訊,請參閱 Microsoft 說明主題 Create and modify peering for an ExpressRoute circuit

  4. 設定客戶端場址設備(CPE)

開始前,請先取得有效的存取權杖。詳情請參閱 建立 API 金鑰

驗證服務金鑰

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

在 Postman 集合中驗證服務金鑰

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

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

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

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

以下是新金鑰的回應範例(尚未設定任何 VXC):

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

megaports:vxc 值對於這兩個 Port 來說都是空值,表示它們可用於新的 VXC。

如需瞭解每個回應欄位的詳細資訊,請參閱Azure 服務金鑰回應欄位

建立並部署 VXCs

利用服務金鑰中的詳細資訊,建立一條連接到主通訊埠的 VXC,以及另一條連接到次通訊埠的 VXC。

建立 VXC

  1. 選取 POST Create VXC to Azure (v3)

    提示

    若您想在下單前測試請求並查看價格詳情,可使用: POST {baseUrl}/v3/networkdesign/validate

  2. 以 Port 的 productUid、VXC 名稱、主 Azure 通訊埠的 productUid,以及服務金鑰來更新請求的 Body。最大速率(rateLimit)在服務金鑰回應的頻寬值已定義,本例為 200。

  3. 點選 Send 送出請求。

    POST {baseUrl}/v3/networkdesign/buy
    
[
    {
        "productUid": "1544f278-ec03-11e5-9ce9-5e5517507c66", //port UID of your Megaport (A-End)
        "associatedVxcs": [
            {
                "productName": "Primary Azure VXC",
                "rateLimit": 200,
                "term":12,
                "shutdown": false,
                "promoCode": "promox3mnthfree2",
                "aEnd": {
                    "vlan": 102
                },
                "bEnd": {
                    "productUid": "a7ae8a35-433e-44aa-87cb-a1b7995ab008", //retrieved port UID from the Azure service key lookup
                    "partnerConfig" : {
                        "connectType": "AZURE",
                        "serviceKey": "3e2480b2-b4d5-424b-976a-7b0de65a1b62" //service key from lookup response
                    }
                }
            }
        ]
    }
]

當您已將主用與備用的 VXC 配置到 Azure 通訊埠後,再次查詢服務金鑰會顯示與 Azure 通訊埠相關聯的 VXC。這些 VXC 會以 ID 編號(megaports:vxc)加以識別。

{
    "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": 60621,
                "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": 60622,
                "port": 16108,
                "companyName": "Azure ExpressRoute",
                "locationId": 67,
                "productId": 16108,
                "type": "secondary",
                "companyId": 1475
            }
        ],
        "peers": []
    }
}

若要完成設定,請在 Azure 入口網站中設定 Peering,並設定你的 CPE 裝置。