为 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 订阅拥有“所有者”或“参与者”访问权限。
- 有权访问要在其中预配 VM 的资源组。
- 有权访问 Azure Stack HCI 群集上的一个或多个 VM 映像。 这些 VM 映像可能是通过以下过程之一创建的:
- 一个用于预配 VM 的 Azure Stack HCI 群集自定义位置。 该自定义位置也会显示在 Azure Stack HCI 群集的“概述”页中。
如果使用客户端连接到 Azure Stack HCI 群集,请参阅 通过 Azure CLI 客户端连接到 Azure Stack HCI。
访问在 Azure Stack HCI 群集上创建的逻辑网络。 有关详细信息,请参阅 创建逻辑网络。
创建网络接口
若要创建 VM,首先需要在逻辑网络上创建网络接口。 步骤可能会有所不同,具体取决于逻辑网络是静态网络还是 DHCP。
登录并设置订阅
连接到 Azure Stack HCI 系统上的服务器。
登录。 键入:
az login --use-device-code
设置订阅。
az account set --subscription <Subscription ID>
具有静态 IP 的虚拟网络接口
按照以下步骤在静态逻辑网络上创建网络接口。 请将 < >
中的参数替换为适当的值。
设置所需的参数。 下面是示例输出:
$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 区域。 例如,这可以是eastus
、westeurope
。subnet-id 逻辑网络的名称。 例如: test-lnet-dynamic
。ip-allocation-method IP 地址分配方法,对于网络接口,可以是 dynamic
或static
。 如果未指定此参数,则默认情况下使用动态配置创建网络接口。ip-address 要分配给要创建的网络接口的 IPv4 地址。 例如:“192.168.0.10”。 若要创建具有静态 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 逻辑网络上创建网络接口。 请将 < >
中的参数替换为适当的值。
设置所需的参数。 下面是示例输出:
$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
。若要创建网络接口,请运行以下命令:
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。
后续步骤
- 在 Azure Stack HCI 上创建 Arc VM 时使用此网络接口。
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈