> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megaport.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Creating a VXC between an MVE and Microsoft Azure with the API

> This help topic describes how to use the Megaport API to create a VXC between a Megaport Virtual Edge (MVE) and an Azure ExpressRoute circuit.

This topic describes the API procedure to create a VXC from an MVE to Microsoft Azure ExpressRoute. Configuration is a two step process: first, you look up Azure interconnect locations with the Azure service key, then you can create the VXC to a specific vNIC on your MVE.

<Note>
  Before you can connect to Azure, you need to set up an ExpressRoute circuit in the Azure console. When set up, you receive a service key with connection details. To configure your MVE connection to Azure, you look up the service key details and then create VXCs to the Azure ports.
</Note>

The MVE to Azure deployment includes these tasks:

1. **Set up an ExpressRoute circuit in the Azure console**

   When deployed, you get a service key. When you validate a service key, you are presented with primary and secondary ports and can choose the port for the connection. You can use the key a second time and create another connection to the unused port.

   For more information, see the Microsoft help topic [Tutorial: Create and modify an ExpressRoute circuit](https://docs.microsoft.com/en-us/azure/expressroute/expressroute-howto-circuit-portal-resource-manager).

2. **Validate the Azure service key**

   When ordering an Azure service, use the service key and ensure there is a free port for a connection.

   The API response includes ExpressRoute details of the associated ports and peers. You need the Azure port details to create the VXC.

3. **Create and deploy a VXC**

   With the validated service key and port details, create the VXC to Microsoft Azure from the MVE.

   As part of the VXC configuration, you can choose the peering type. The peering type can be either private or Microsoft.

   A defined peering type results in automatically configured peering with peers matched on both the Azure and Megaport sides and a deployed system with a known working configuration. You can modify the configuration once deployed.

Before you begin, obtain a valid access token. For more information, see [Creating an API Key](/api/api-key).

## Validate the service key

Use the API to validate a Microsoft Azure service key. The response includes ExpressRoute details of the associated ports and peers. You need the Azure port details to create the VXC.

Review the service key and ensure there is a free Port for a connection. In the API response, available ports are listed as `"vxc":null` and ports with an assigned value are not available.

For more information about each response field, see [Azure Service Key Response Fields](/api/api-azure-servicekey).

**To validate the service key**

* Use the **GET Look Up Azure Service Key** API to look up Microsoft Azure location details with the service key:

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

Here is a sample response for a pairing key with an available port (vxc = null).

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "Successful lookup",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": {
       "bandwidth": 50,
       "connectType": "AZURE",
       "managed": false,
       "megaports": [
           {
               "productId": 53013,
               "productUid": "83f95deb-a537-485e-80d9-c442c776ddc9",
               "name": "London Primary",
               "nServiceId": 119129,
               "description": "Azure ExpressRoute at Equinix LD5",
               "companyId": 1475,
               "companyUid": "c40de5ed-4707-4471-a78c-69436de2c505",
               "companyName": "Azure ExpressRoute",
               "portSpeed": 10000,
               "locationId": 90,
               "state": null,
               "country": "United Kingdom",
               "port": 53013,
               "type": "primary",
               "vxc": null
           },
           {
               "productId": 53014,
               "productUid": "d84ad163-8e22-4150-8cb7-44f1aecf9e90",
               "name": "London Secondary",
               "nServiceId": 119130,
               "description": "Azure ExpressRoute at Equinix LD5",
               "companyId": 1475,
               "companyUid": "c40de5ed-4707-4471-a78c-69436de2c505",
               "companyName": "Azure ExpressRoute",
               "portSpeed": 10000,
               "locationId": 90,
               "state": null,
               "country": "United Kingdom",
               "port": 53014,
               "type": "secondary",
               "vxc": null
           }
       ],
       "peers": [],
       "resource_type": "csp_connection",
       "service_key": "3f0f66b9-0c82-4d61-ae31-f5985c841a4a",
       "vlan": 19
   }
}

```

## Create and deploy a VXC to a specific vNIC

With the Azure ExpressRoute port details from the service key lookup, create the VXC to Azure.

You specify the configuration details in the Body of the request. The first `productUid` identifies the MVE and the `bEnd: productUid` identifies the Azure interface. You also need to provide the Azure ExpressRoute service key in `serviceKey` field.

<Tip>
  Look up Azure locations for the B-End of the connection with the `v2/dropdowns/partner/megaports` endpoint.
</Tip>

You can create multiple connections to an Azure interface, for example, if you need to connect both private and Microsoft peers to the same interface.

### Single Azure Peering VLAN

In this example, Single Azure Peering VLAN is used. You can tell this because the aEnd innerVlan and the bEnd innerVlan are specified. For Single Azure Peering VLAN both are set to the same value.

If this value is set to `0`, a valid inner VLAN will be allocated and set by the system.

<Tip>
  To test your request before you order and see pricing details, use the `/v3/networkdesign/validate` endpoint with the same Body configuration.
</Tip>

**To create a VXC**

1. Create a request with the **POST Create VXC to Azure (v3)** endpoint:

   ```http theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
   POST {baseUrl}/v3/networkdesign/buy
   ```

2. Update the Body of the request with the `productUid` of the MVE, the name of the VXC, the `productUid` of the Azure port, and set the service key `innerVlan` to 501 and `vNicIndex` to 0 (interface 1).

<Note>
  The vNIC number relates to the following MVE interfaces:

  * vNIC 0 = interface 1 on the MVE
  * vNIC 1 = interface 2 on the MVE
  * vNIC 2 = interface 3 on the MVE
  * vNIC 3 = interface 4 on the MVE
  * vNIC 4 = interface 5 on the MVE
</Note>

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
[
  {
   "productUid": "{ mveid }",
    "associatedVxcs": [
      {
        "productName": "Link to Azure ",
        "partnerConfigs" : {
           "connectType": "AZURE",
           "serviceKey": "((azureServiceKey}}"
        },
        "rateLimit": 1000,
        "term": 12,
        "shutdown": false,
        "promoCode": "promox3mnthfree2",
        "aEnd": {
          "vNicIndex":0,
          "innerVlan": 501
        },
        "bEnd": {
               "productUid": "{ azurePortUid }",
          "innerVlan": 501
        }
      }
    ]
  }
]

```

After sending the request, you will receive a successful response when the VXC has been ordered.

Here is a sample response:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
    "message": "VXC [7f7c22f6-5cde-45d7-8603-f3546c714118] created.",
    "terms": "This data is subject to the Acceptable Use Policy https://www.megaport.com/legal/acceptable-use-policy",
    "data": [
       {
           "createDate": 1709822378799,
           "vxcOrderId": 139947,
           "payerMegaPortId": 190079,
           "nonPayerMegaPortId": 53013,
           "payerMegaPortName": "MVE for VNIC config",
           "nonPayerMegaPortName": "London Primary",
           "payerCompanyId": 1153,
           "nonPayerCompanyId": 1475,
           "payerLocationId": 89,
           "nonPayerLocationId": 90,
           "salesId": null,
           "payerCompanyName": "Megaport Lab",
           "nonPayerCompanyName": "Azure ExpressRoute",
           "payerMegaPortNsId": 510708,
           "nonPayerMegaPortNsId": 119129,
           "payerVlanId": 0,
           "nonPayerVlanId": 0,
           "payerInnerVlanId": 501,
           "nonPayerInnerVlanId": 501,
           "payerApproverName": "name",
           "payerApproverId": 41315,
           "nonPayerApproverName": "name",
           "nonPayerApproverId": number,
           "payerApproval": number,
           "nonPayerApproval": number,
           "fixedTerm": true,
           "duration": 1,
           "rollover": true,
           "serviceName": "from MVE for VNIC config to London Primary",
           "payerStatus": "APPROVED",
           "nonPayerStatus": "APPROVED",
           "speed": 1000,
           "distanceBand": "METRO",
           "intercapPath": "",
           "awsId": null,
           "promoCode": null,
           "rateType": "MONTHLY",
           "vxcJTechnicalServiceId": 190104,
           "vxcJTechnicalServiceUid": "7f7c22f6-5cde-45d7-8603-f3546c714118",
           "provisionDate": 1709822378782,
           "orderType": "NEW",
           "monthlyDiscountAmount": null,
           "discountMonths": null,
           "amazonDirectConnectConfigDto": null,
           "amsixConnectConfigDto": null,
           "sdrcProvItem": null,
           "rate": null,
           "setup": null,
           "asn": null,
           "bgpPassword": null,
           "usageAlgorithm": "POST_PAID_HOURLY_SPEED_METRO_VXC",
           "costCentre": null,
           "azureServiceKey": "{ azureServiceKey }",
           "oracleVirtualCircuitId": null,
           "serviceKey": null,
           "vxc": {
               "serviceName": "Link to Azure ",
               "name": "Link to Azure ",
               "secondaryName": null,
               "technicalServiceId": 190104,
               "technicalServiceUid": "7f7c22f6-5cde-45d7-8603-f3546c714118",
               "requestedDate": 1709822378782,
               "configuredDate": null,
               "currentEstimatedDelivery": null,
               "companyName": "Megaport Lab",
               "companyId": 1153,
               "billingContactName": null,
               "billingContactId": null,
               "adminContactName": null,
               "adminContactId": null,
               "technicalContactName": null,
               "technicalContactId": null,
               "salesName": null,
               "salesId": null,
               "billableId": 181652,
               "billableUsageAlgorithm": null,
               "productType": "VXC",
               "provisioningStatus": "DEPLOYABLE",
               "failedReason": null,
               "inAdvanceBillingStatus": null,
               "provisioningItems": [],
               "tags": [],
               "vxcDistanceBand": "METRO",
               "intercapPath": "",
               "marketplaceVisibility": true,
               "vxcPermitted": true,
               "vxcAutoApproval": false,
               "createDate": 1709822378792,
               "terminationDate": null,
               "contractStartDate": null,
               "contractTermMonths": 1,
               "rateType": "MONTHLY",
               "trialAgreement": false,
               "payerCompanyId": null,
               "nonPayerCompanyId": null,
               "minimumSpeed": null,
               "maximumSpeed": null,
               "rateLimit": 1000,
               "errorMessage": null,
               "lagId": null,
               "aggregationId": null,
               "lagPrimary": null,
               "market": "UK",
               "accountManager": null,
               "promptUid": null,
               "components": [],
               "attributes": [],
               "aLocation": null,
               "bLocation": null,
               "aMetro": null,
               "aCountry": null,
               "aLocationId": null,
               "bLocationId": null,
               "bMetro": null,
               "bCountry": null,
               "attributeTags": {},
               "createdBy": "b0dedbd2-ecc7-4bad-a13b-6c34b4005115",
               "buyoutPort": null,
               "virtual": false,
               "locked": false,
               "adminLocked": false,
               "bgpShutdownDefault": false
           },
           "connectType": "AZURE",
           "payerConfig": {},
           "nonPayerConfig": {},
           "attributeTags": {},
           "serviceLicense": null,
           "fullyApproved": true
       }
   ]
}

```

### Multiple Microsoft peerings (Q-in-Q)

If you do not want to use Single Azure Peering VLAN and want to use Q-in-Q to have multi Microsoft peerings on a single VXC, only specify the aEnd innerVlan value.

With Q-in-Q in play, the Azure peering VLAN ID set in Azure is not shown in the Megaport APIs or Portal. It is configured by the customer in the Azure ExpressRoute peerings and matched on the MVE instance configuration.

In the example below, the aEnd innerVlan field of 100 is actually an outer vlan or s-tag on the MVE. The Q-in-Q inner VLAN (c-tag) running inside the innerVlan is transparent to Megaport.

<Note>
  Azure VXCs are the only cloud VXC type that allow you to specify a double-tagged VXC.
</Note>

Here is a sample request:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}

[
 {
"productUid": "02ec2091-46bb-4904-bd17-96c752ff826e",
 "associatedVxcs": [
   {
     "productName": "My New Azure VXC",
     "partnerConfigs" : {
        "connectType": "AZURE",
        "serviceKey": "{ service_key }"
     },
     "rateLimit": 1000,
     "term": 12,
     "shutdown": false,
     "aEnd": {
       "innerVlan": 100
     },
     "bEnd": {
       "productUid": "{ azurepuid }"
     }
   }
 ]
 }
]

```
