Create Azure Stack HCI 上的 Arc 虛擬機

適用於:Azure Stack HCI 版本 23H2

本文說明如何從您在 Azure Stack HCI 叢集上建立的 VM 映射開始建立 Arc VM。 您可以使用 Azure CLI、Azure 入口網站 或 Azure Resource Manager (ARM) 範本來建立 Arc VM。

關於 Azure Stack HCI 叢集資源

使用 Azure Stack HCI 叢集資源頁面 進行下列作業:

  • Create 和管理Arc VM資源,例如VM映像、磁碟、網路介面。
  • 檢視及存取與 Azure Stack HCI 叢集相關聯的 Azure Arc 資源網橋和自定義位置。
  • 布建和管理Arc VM。

下一節將說明建立Arc VM的程式。

必要條件

建立已啟用 Azure Arc 的 VM 之前,請確定下列必要條件已完成。

  • 如果使用用戶端連線到您的 Azure Stack HCI 叢集,請參閱 透過 Azure CLI 用戶端連線到 Azure Stack HCI

  • 存取您已在與 Azure Stack HCI 叢集相關聯的邏輯網路上建立的網路介面。 您可以選擇具有靜態 IP 的網路介面,或具有動態 IP 配置的網路介面。 如需詳細資訊,請參閱如何 Create 網路介面

Create Arc VM

請遵循下列步驟,在 Azure Stack HCI 叢集上建立 Arc VM。

請依照執行連線至 Azure Stack HCI 叢集之 az CLI 的客戶端執行下列步驟。

登入並設定訂用帳戶

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

  2. 登入。 輸入:

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

    az account set --subscription <Subscription ID>
    

建立 Windows VM

視您建立的網路介面類型而定,您可以建立具有具有靜態IP的網路介面的VM,或具有動態IP配置的VM。

注意

如果您需要一個以上的網路介面搭配 VM 的靜態 IP,請先建立介面 () ,再建立 VM。 不支援在布建 VM 之後新增具有靜態 IP 的網路介面。

在這裡,我們將建立使用指定記憶體路徑上特定記憶體和處理器計數的 VM。

  1. 設定部分參數。

    $vmName ="myhci-vm"
    $subscription =  "<Subscription ID>"
    $resource_group = "myhci-rg"
    $customLocationName = "myhci-cl"
    $customLocationID ="/subscriptions/$subscription/resourceGroups/$resource_group/providers/Microsoft.ExtendedLocation/customLocations/$customLocationName"
    $location = "eastus"
    $computerName = "mycomputer"
    $userName = "myhci-user"
    $password = "<Password for the VM>"
    $imageName ="ws22server"
    $nicName ="myhci-vnic" 
    $storagePathName = "myhci-sp" 
    $storagePathId = "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/storagecontainers/myhci-sp" 
    

    VM 建立的參數會以表格式顯示,如下所示:

    參數 描述
    name 您為 Azure Stack HCI 叢集建立的 VM 名稱。 請務必提供遵循 Azure 資源規則的名稱。
    admin-username 您在 Azure Stack HCI 叢集上部署之 VM 上使用者的使用者名稱。
    admin-password 您在 Azure Stack HCI 叢集上部署之 VM 上的使用者密碼。
    image-name 用來布建 VM 的 VM 映像名稱。
    位置 由所指定的 az locationsAzure 區域。 例如,這可能是 eastuswesteurope
    resource-group 您建立 VM 的資源群組名稱。 為了方便管理,我們建議您使用與 Azure Stack HCI 叢集相同的資源群組。
    訂用帳戶 部署 Azure Stack HCI 之訂用帳戶的名稱或標識碼。 這可能是您在 Azure Stack HCI 叢集上用於 VM 的另一個訂用帳戶。
    custom-location 使用此專案來提供與您正在建立此 VM 的 Azure Stack HCI 叢集相關聯的自定義位置。
    authentication-type 要與 VM 搭配使用的驗證類型。 接受的值為 allpasswordssh。 預設為適用於Linux的 Windows 和 SSH 公鑰的密碼。 使用 all 來啟用 sshpassword 驗證。
    nics 與 VM 相關聯的網路介面名稱或標識碼。 建立 VM 時,您至少必須有一個網路介面,才能啟用客體管理。
    memory-mb 配置給 VM 的記憶體以 MB 為單位。 如果未指定,則會使用預設值。
    處理器 配置給 VM 的處理器數目。 如果未指定,則會使用預設值。
    storage-path-id VM 組態和數據儲存所在的相關聯記憶體路徑。
    proxy-configuration 使用此選擇性參數來設定 VM 的 Proxy 伺服器。 如需詳細資訊,請參閱 Create 已設定 Proxy 的 VM
  2. 執行下列命令以建立 VM。

     az stack-hci-vm create --name $vmName --resource-group $resource_group --admin-username $userName --admin-password $password --computer-name $computerName --image $imageName --location $location --authentication-type all --nics $nicName --custom-location $customLocationID --hardware-profile memory-mb="8192" processors="4" --storage-path-id $storagePathId 
    

當 顯示為succeeded輸出時provisioningState,就會成功建立 VM。

注意

建立的 VM 預設會啟用客體管理。 如果基於任何原因,客體管理在 VM 建立期間失敗,您可以遵循 在 Arc VM 上啟用客體管理 中的步驟,在 VM 建立之後加以啟用。

在此範例中,已使用 --storage-path-id 旗標指定記憶體路徑,並確保工作負載數據 (包括 VM、VM 映射、非 OS 數據磁碟) 放在指定的記憶體路徑中。

如果未指定旗標,工作負載 (VM、VM 映射、非 OS 數據磁碟) 會自動放在高可用性記憶體路徑中。

建立 Linux VM

若要建立Linux VM,請使用您用來建立 Windows VM 的相同命令。

  • 指定的資源庫映像應該是Linux映像。
  • 用戶名稱和密碼可搭配 參數使用 authentication-type-all
  • 針對 SSH 金鑰,您必須連同 authentication-type-all傳遞ssh-key-values參數。

重要

Linux VM 不支援在 VM 建立期間設定 Proxy 伺服器。

Create 已設定 Proxy 的 VM

使用此選擇性參數 Proxy 組態 來設定 VM 的 Proxy 伺服器。

如果在 Proxy 伺服器後方建立 VM,請執行下列命令:

az stack-hci-vm create --name $vmName --resource-group $resource_group --admin-username $userName --admin-password $password --computer-name $computerName --image $imageName --location $location --authentication-type all --nics $nicName --custom-location $customLocationID --hardware-profile memory-mb="8192" processors="4" --storage-path-id $storagePathId --proxy-configuration http_proxy="<Http URL of proxy server>" https_proxy="<Https URL of proxy server>" no_proxy="<URLs which bypass proxy>" cert_file_path="<Certificate file path for your server>" 

您可以針對 proxy-server-configuration輸入下列參數:

參數 描述
http_proxy Proxy 伺服器的 HTTP URL。 範例 URL 為:http://proxy.example.com:3128
https_proxy Proxy 伺服器的 HTTPS URL。 伺服器仍可使用 HTTP 位址,如下列範例所示: http://proxy.example.com:3128
no_proxy 可略過 Proxy 的 URL。 典型的範例為 localhost,127.0.0.1,.svc,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.0.0.0/8
cert_file_path Proxy 伺服器的憑證檔案路徑名稱。 例如:C:\Users\Palomino\proxycert.crt

以下是範例命令:

az stack-hci-vm create --name $vmName --resource-group $resource_group --admin-username $userName --admin-password $password --computer-name $computerName --image $imageName --location $location --authentication-type all --nics $nicName --custom-location $customLocationID --hardware-profile memory-mb="8192" processors="4" --storage-path-id $storagePathId --proxy-configuration http_proxy="http://ubuntu:ubuntu@192.168.200.200:3128" https_proxy="http://ubuntu:ubuntu@192.168.200.200:3128" no_proxy="localhost,127.0.0.1,.svc,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,100.0.0.0/8,s-cluster.test.contoso.com" cert_file_path="C:\ClusterStorage\UserStorage_1\server.crt"

針對 Proxy 驗證,您可以傳遞 URL 中結合的使用者名稱和密碼,如下所示:"http://username:password@proxyserver.contoso.com:3128"

視您在 VM 上執行的 PowerShell 版本而定,您可能需要啟用 VM 的 Proxy 設定。

  • 針對執行 PowerShell 5.1 版或更早版本的 Windows VM,請在建立之後登入 VM。 執行下列命令以啟用 Proxy:

    netsh winhttp set proxy proxy-server="http=myproxy;https=sproxy:88" bypass-list="*.foo.com"
    

    啟用 Proxy 之後,您就可以 啟用來賓管理

  • 對於執行 PowerShell 5.1 版之後的 Windows VM,在 VM 建立期間傳遞的 Proxy 設定只會用於啟用 Arc 客體管理。 建立 VM 之後,請登入 VM 並執行上述命令來啟用其他應用程式的 Proxy。

使用受控識別來驗證Arc VM

透過 Azure CLI 或 Azure 入口網站 在 Azure Stack HCI 系統上建立 Arc VM 時,也會建立系統指派的受控識別,其存留期為 Arc VM 的存留期。

Azure Stack HCI 上的 Arc VM 會從已啟用 Arc 的伺服器延伸,而且可以使用系統指派的受控識別來存取支援 Microsoft Entra ID 型驗證的其他 Azure 資源。 例如,Arc VM 可以使用系統指派的受控識別來存取 Azure 金鑰保存庫。

如需詳細資訊,請參閱 系統指派的受控識別使用已啟用 Azure Arc 的伺服器對 Azure 資源進行驗證

下一步