为 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。

先决条件

在创建网络接口之前,请确保满足以下先决条件。

创建网络接口

若要创建 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 资源规则的名称。 创建网络接口后,无法重命名该网络接口。
    resource-group 部署 Azure Stack HCI 的资源组的名称。 也可以是其他预先创建的资源组。
    subscription 部署 Azure Stack HCI 的订阅的名称或 ID。 这可能是用于 Azure Stack HCI 群集上的逻辑网络的另一个订阅。
    custom-location 要用于 Azure Stack HCI 群集上逻辑网络的自定义位置的名称或 ID。
    location az locations 指定的 Azure 区域。 例如,这可以是 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 资源规则的名称。 创建网络接口后,无法重命名该网络接口。
    resource-group 部署 Azure Stack HCI 的资源组的名称。 也可以是其他预先创建的资源组。
    subscription 部署 Azure Stack HCI 的订阅的名称或 ID。 这可能是用于 Azure Stack HCI 群集上的逻辑网络的另一个订阅。
    custom-location 要用于 Azure Stack HCI 群集上逻辑网络的自定义位置的名称或 ID。
    location az locations 指定的 Azure 区域。 例如,它可以是 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

后续步骤