共用方式為


在 Azure Stack HCI 上建立 Arc 虛擬機的網路介面

適用於:Azure Stack HCI 版本 23H2

本文說明如何建立網路介面,以便與 Azure Stack HCI 叢集上的 Arc VM 產生關聯。 您可以使用 Azure 入口網站 或 Azure CLI 來建立網路介面。

關於網路介面

網路介面是 Azure 資源,可用來在叢集上部署虛擬機。 建立邏輯網路之後,您可以建立網路介面,並將這些網路介面與您將建立的虛擬機產生關聯。

您可以使用 Azure 入口網站 或 Azure CLI 來建立網路介面。 使用 Azure 入口網站 時,網路介面建立是 VM 建立程式的一部分。 使用 Azure CLI 時,您可以先建立網路介面,然後使用它來建立 VM。

必要條件

建立網路介面之前,請確定下列必要條件已完成。

  • 請務必檢閱並 完成必要條件。 如果使用用戶端連線到 Azure Stack HCI 叢集,請參閱 遠端連線到叢集。

  • 存取您在 Azure Stack HCI 叢集上建立的邏輯網路。 如需詳細資訊,請參閱 建立邏輯網路

建立網路介面

若要建立 VM,您必須先在邏輯網路上建立網路介面。 視邏輯網路是靜態還是 DHCP 而定,這些步驟可能會有所不同。

登入並設定訂用帳戶

  1. 線上到 Azure Stack HCI 系統上的伺服器。

  2. 登入。 輸入:

    az login --use-device-code
    
  3. 設定您的訂用帳戶。

    az account set --subscription <Subscription ID>
    

具有靜態IP的虛擬網路介面

請遵循下列步驟,在您的靜態邏輯網路上建立網路介面。 將中的 < > 參數取代為適當的值。

  1. 設定必要參數。 以下是範例輸出:

    $lnetName = "myhci-lnet-static"
    $gateway ="100.68.180.1" 
    $ipAddress ="100.68.180.6" 
    $nicName ="myhci-nic-static"
    $subscription =  "<Subscription ID>"
    $resource_group = "myhci-rg"
    $customLocationName = "myhci-cl" 
    $customLocationID ="/subscriptions/$subscription/resourceGroups/$resource_group/providers/Microsoft.ExtendedLocation/customLocations/$customLocationName"
    $location = "eastus"
    

    以下是參數的描述:

    參數 描述:
    name 您將在 Azure Stack HCI 叢集上部署之邏輯網路上建立的網路介面名稱。 請務必提供遵循 Azure 資源規則的名稱。 您無法在建立網路介面之後重新命名。
    資源群組 部署 Azure Stack HCI 的資源群組名稱。 這也可能是另一個預先建立的資源群組。
    訂閱 部署 Azure Stack HCI 之訂用帳戶的名稱或標識碼。 這可能是您在 Azure Stack HCI 叢集上用於邏輯網路的另一個訂用帳戶。
    custom-location 要用於 Azure Stack HCI 叢集上邏輯網路之自定義位置的名稱或標識碼。
    位置 Azure 區域,如 所 az locations指定。 例如,這可能是 eastuswesteurope
    subnet-id 邏輯網路的名稱。 例如: test-lnet-dynamic
    ip-allocation-method IP 位址設定方法,可以是 dynamicstatic 適用於您的網路介面。 如果未指定此參數,預設會使用動態組態建立網路介面。
    ip-address 您想要指派給所建立網路介面的 IPv4 位址。 例如:「192.168.0.10」。。
  2. 若要建立具有靜態 IP 位址的網路介面,請執行下列命令:

    az stack-hci-vm network nic create --subscription $subscription --resource-group $resource_group --custom-location $customLocationID --location $location --name $nicName --subnet-id $lnetName --ip-address $ipAddress
    

    以下是範例輸出:

    {
      "extendedLocation": {
        "name": "/subscriptions/<subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.ExtendedLocation/customLocations/myhci-cl",
        "type": "CustomLocation"
      },
      "id": "/subscriptions/<subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/networkinterfaces/myhci-nic-static",
      "location": "eastus",
      "name": "myhci-nic-static",
      "properties": {
        "dnsSettings": {
          "dnsServers": null
        },
        "ipConfigurations": [
          {
            "name": null,
            "properties": {
              "gateway": "192.168.200.1",
              "prefixLength": "24",
              "privateIpAddress": "192.168.201.3",
              "privateIpAllocationMethod": null,
              "subnet": {
                "id": "/subscriptions/<subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/logicalnetworks/myhci-lnet-static",
                "resourceGroup": "myhci-rg"
              }
            }
          }
        ],
        "macAddress": null,
        "provisioningState": "Succeeded",
        "resourceName": null,
        "status": {}
      },
      "resourceGroup": "myhci-rg",
      "systemData": {
        "createdAt": "2023-11-02T23:00:47.714910+00:00",
        "createdBy": "guspinto@contoso.com",
        "createdByType": "User",
        "lastModifiedAt": "2023-11-02T23:02:08.720545+00:00",
        "lastModifiedBy": "<ID>",
        "lastModifiedByType": "Application"
      },
      "tags": null,
      "type": "microsoft.azurestackhci/networkinterfaces"
    } 
    

使用 DHCP 的虛擬網路介面

請遵循下列步驟,在您的 DHCP 邏輯網路上建立網路介面。 將中的 < > 參數取代為適當的值。

  1. 設定必要參數。 以下是範例輸出:

    $nicName = "myhci-nic-dhcp"
    $lnetName = "myhci-lnet-dhcp"   
    $subscription =  "<subscription ID>" 
    $resource_group = "myhci-rg"
    $customLocationName = "myhci-cl" 
    $customLocationID ="/subscriptions/$subscription/resourceGroups/$resource_group/providers/Microsoft.ExtendedLocation/customLocations/$customLocationName"
    $location = "eastus"
    

    以下是參數的描述:

    參數 描述:
    name 您將在 Azure Stack HCI 叢集上部署之邏輯網路上建立的網路介面名稱。 請務必提供遵循 Azure 資源規則的名稱。 您無法在建立網路介面之後重新命名。
    資源群組 部署 Azure Stack HCI 的資源群組名稱。 這也可能是另一個預先建立的資源群組。
    訂閱 部署 Azure Stack HCI 之訂用帳戶的名稱或標識碼。 這可能是您在 Azure Stack HCI 叢集上用於邏輯網路的另一個訂用帳戶。
    custom-location 要用於 Azure Stack HCI 叢集上邏輯網路之自定義位置的名稱或標識碼。
    位置 Azure 區域,如 所 az locations指定。 例如,這可能是 eastus
    subnet-id 邏輯網路的名稱。 例如: test-lnet-dynamic
  2. 若要建立網路介面,請執行下列命令:

    az stack-hci-vm network nic create --subscription $subscription --resource-group $resource_group --custom-location $customLocationID --location $location --name $nicName --subnet-id $lnetName
    

    以下是範例輸出:

    {
      "extendedLocation": {
        "name": "/subscriptions/<subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.ExtendedLocation/customLocations/myhci-cl",
        "type": "CustomLocation"
      },
      "id": "/subscriptions/<subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/networkinterfaces/myhci-vnic",
      "location": "eastus",
      "name": "myhci-nic-dhcp",
      "properties": {
        "ipConfigurations": [
          {
            "name": null,
            "properties": {
              "gateway": null,
              "prefixLength": null,
              "privateIpAddress": null,
              "privateIpAllocationMethod": null,
              "subnet": {
                "id": "myhci-lnet-dhcp"
              }
            }
          }
        ],
        "macAddress": null,
        "provisioningState": "Succeeded",
        "resourceName": "myhci-nic-dhcp",
        "status": {}
      },
      "resourceGroup": "myhci-rg",
      "systemData": {
        "createdAt": "2023-02-08T23:25:10.984508+00:00",
        "createdBy": "guspinto@contoso.com",
        "createdByType": "User",
        "lastModifiedAt": "2023-02-08T23:26:03.262252+00:00",
        "lastModifiedBy": "<ID>",
        "lastModifiedByType": "Application"
      },
      "tags": null,
      "type": "microsoft.azurestackhci/networkinterfaces"
    }
    PS C:\windows\system32> 
    

您可以使用此網路介面來建立 VM。 如需詳細資訊,請參閱 建立 VM

下一步