使用本機共用中的映像建立 Azure Stack HCI VM 映像
適用於:Azure Stack HCI 版本 23H2
本文說明如何使用叢集上本機共用的來源映像,為 Azure Stack HCI 建立虛擬機 (VM) 映像。 您可以使用 Azure 入口網站 或 Azure CLI 建立 VM 映射,然後使用這些 VM 映射在 Azure Stack HCI 上建立 Arc VM。
必要條件
開始之前,請確定已完成下列必要條件。
請務必檢閱並 完成必要條件。
您可以存取已部署的 Azure Stack HCI 系統,具有 Arc Resource Bridge 和自定義位置。
針對 Azure Stack HCI 上本機共用中的自定義映射,您將具備下列額外必要條件:
- 您應該已將 VHD/VHDX 上傳至 Azure Stack HCI 叢集上的本機共用。
- VHDX 映射必須是第 2 代類型,且已啟用安全開機。
- 必須使用 準備
sysprep /generalize /shutdown /oobe
VHDX 映像。 如需詳細資訊,請參閱 Sysprep 命令行選項。 - 映像應該位於叢集中所有伺服器可用的叢集共用磁碟區上。 支援 Windows 和 Linux 作業系統。
- 如果使用用戶端連線到您的 Azure Stack HCI 叢集,請參閱 透過 Azure CLI 用戶端連線到 Azure Stack HCI。
從本機共用中的映像新增 VM 映像
您可以從叢集本機共用中的映射建立 VM 映射,然後使用此映射在 Azure Stack HCI 叢集上部署 VM。
請遵循下列步驟,使用 Azure CLI 建立 VM 映射。
登入並設定訂用帳戶
線上到 Azure Stack HCI 系統上的伺服器。
登入。 輸入:
az login --use-device-code
設定您的訂用帳戶。
az account set --subscription <Subscription ID>
設定一些參數
設定映像的訂用帳戶、資源群組、位置、OS 類型。 將中的
< >
參數取代為適當的值。$subscription = "<Subscription ID>" $resource_group = "<Resource group>" $location = "<Location for your Azure Stack HCI cluster>" $imageName = <VM image name> $imageSourcePath = <path to the source image> $osType = "<OS of source image>"
下表會說明這些參數:
參數 Description subscription
您與此映像相關聯的 Azure Stack HCI 叢集資源群組。 resource_group
您與此映像相關聯的 Azure Stack HCI 叢集資源群組。 location
Azure Stack HCI 叢集的位置。 例如,這可能是 eastus
。image-path
從本機共用中的映像開始建立的 VM 映像名稱。
注意:Azure 會拒絕包含關鍵詞 Windows 的所有名稱。name
來源資源庫映像的路徑 (VHDX 只在叢集上) 。 例如 ,C:\OSImages\winos.vhdx。 請參閱來源映像的必要條件。 os-type
與來源映像相關聯的操作系統。 這可以是 Windows 或 Linux。 以下是範例輸出:
PS C:\Users\azcli> $subscription = "<Subscription ID>" PS C:\Users\azcli> $resource_group = "myhci-rg" PS C:\Users\azcli> $location = "eastus" PS C:\Users\azcli> $osType = "Windows" PS C:\ClusterStorage\Volume1> $imageName = "myhci-localimage" PS C:\ClusterStorage\Volume1> $imageSourcePath = "C:\ClusterStorage\Volume1\Windows_K8s_17763.2928.220505-1621_202205101158.vhdx"
從本機共用中的映像建立 VM 映像
選取自定義位置以部署 VM 映像。 自定義位置應對應至 Azure Stack HCI 叢集的自定義位置。 取得 Azure Stack HCI 叢集的自定義位置識別碼。 執行以下命令:
$customLocationID=(az customlocation show --resource-group $resource_group --name "<custom location name for HCI cluster>" --query id -o tsv)
建立 VM 映射,從 Azure Stack HCI 叢集上的本機共用中指定的映像開始。
az stack-hci-vm image create --subscription $subscription --resource-group $resource_group --custom-location $customLocationID --location $location --image-path $ImageSourcePath --name $ImageName --os-type $osType --storage-path-id $storagepathid
VM 映射的部署作業隨即啟動。
在此範例中,記憶體路徑是使用
--storage-path-id
旗標指定,並確保工作負載數據 (包括 VM、VM 映射、非 OS 數據磁碟) 放在指定的記憶體路徑中。如果未指定旗標,工作負載數據會自動放在高可用性記憶體路徑中。
映射部署需要幾分鐘的時間才能完成。 下載映像所花費的時間取決於本機共用中的映像大小,以及可供下載的網路頻寬。
以下是範例輸出:
PS C:\Users\azcli> $customLocationID=(az customlocation show --resource-group $resource_group --name "myhci-cl" --query id -o tsv)
PS C:\Users\azcli> az stack-hci-vm image create --subscription $subscription --resource-group $resource_group --custom-location $customLocationID --location $location --image-path $ImageSourcePath --name $ImageName --os-type $osType --storage-path-id $storagepathid
type="CustomLocation" --location $Location --name $mktplaceImage --os-type $osType --image-path $mktImageSourcePath
Command group 'azurestackhci' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
{
"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/galleryimages/myhci-localimage",
"location": "eastus",
"name": "myhci-localimage",
"properties": {
"identifier": null,
"imagePath": null,
"osType": "Windows",
"provisioningState": "Succeeded",
"status": {
"downloadStatus": {},
"progressPercentage": 100,
"provisioningStatus": {
"operationId": "82f58893-b252-43db-97a9-258f6f7831d9*43114797B86E6D2B28C4B52B02302C81C889DABDD9D890F993665E223A5947C3",
"status": "Succeeded"
}
},
"storagepathId": "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/storagecontainers/myhci-storagepath",
"version": {
"name": null,
"properties": {
"storageProfile": {
"osDiskImage": {}
}
}
}
},
"resourceGroup": "myhci-rg",
"systemData": {
"createdAt": "2023-11-02T06:15:10.450908+00:00",
"createdBy": "guspinto@contoso.com",
"createdByType": "User",
"lastModifiedAt": "2023-11-02T06:15:56.689323+00:00",
"lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
"lastModifiedByType": "Application"
},
"tags": null,
"type": "microsoft.azurestackhci/galleryimages"
}
PS C:\Users\azcli>
列出 VM 映像
您必須檢視 VM 映射清單,以選擇要管理的映像。
請遵循下列步驟,使用 Azure CLI 列出 VM 映射。
以系統管理員身分執行 PowerShell。
設定部分參數。
$subscription = "<Subscription ID associated with your cluster>" $resource_group = "<Resource group name for your cluster>"
列出與叢集相關聯的所有 VM 映像。 執行以下命令:
az stack-hci-vm image list --subscription $subscription --resource-group $resource_group
根據所使用的命令,會列出與 Azure Stack HCI 叢集相關聯的對應映像集。
- 如果您只指定訂用帳戶,命令會列出訂用帳戶中的所有映像。
- 如果您同時指定訂用帳戶和資源群組,命令會列出資源群組中的所有映像。
這些映像包括:
- 來自市集映像的 VM 映像。
- 位於 Azure 記憶體帳戶中的自訂映像,或位於叢集或連線至叢集的用戶端上的本機共用中。
以下是範例輸出。
PS C:\Users\azcli> az stack-hci-vm image list --subscription "<Subscription ID>" --resource-group "myhci-rg"
Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
[
{
"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/marketplacegalleryimages/w
inServer2022Az-01",
"location": "eastus",
"name": "winServer2022Az-01",
"properties": {
"hyperVGeneration": "V2",
"identifier": {
"offer": "windowsserver",
"publisher": "microsoftwindowsserver",
"sku": "2022-datacenter-azure-edition-core"
},
"imagePath": null,
"osType": "Windows",
"provisioningState": "Succeeded",
"status": {
"downloadStatus": {
"downloadSizeInMB": 6710
},
"progressPercentage": 100,
"provisioningStatus": {
"operationId": "19742d69-4a00-4086-8f17-4dc1f7ee6681*E1E9889F0D1840B93150BD74D428EAE483CB67B0904F9A198C161AD471F670ED",
"status": "Succeeded"
}
},
"storagepathId": null,
"version": {
"name": "20348.2031.231006",
"properties": {
"storageProfile": {
"osDiskImage": {
"sizeInMB": 130050
}
}
}
}
},
"resourceGroup": "myhci-rg",
"systemData": {
"createdAt": "2023-10-30T21:44:53.020512+00:00",
"createdBy": "guspinto@contoso.com",
"createdByType": "User",
"lastModifiedAt": "2023-10-30T22:08:25.495995+00:00",
"lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
"lastModifiedByType": "Application"
},
"tags": {},
"type": "microsoft.azurestackhci/marketplacegalleryimages"
}
]
PS C:\Users\azcli>
檢視 VM 映像屬性
您可能想要先檢視 VM 映像的屬性,再使用映像來建立 VM。 請遵循下列步驟來檢視影像屬性:
請遵循下列步驟,使用 Azure CLI 來檢視映像的屬性:
以系統管理員身分執行 PowerShell。
設定下列參數。
$subscription = "<Subscription ID>" $resource_group = "<Cluster resource group>" $mktplaceImage = "<Marketplace image name>"
您可以透過兩種不同的方式檢視影像屬性:指定識別碼或指定名稱和資源群組。 指定 Marketplace 映射識別符時,請執行下列步驟:
設定下列參數。
$mktplaceImageID = "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/galleryimages/myhci-marketplaceimage"
執行下列命令以檢視屬性。
az stack-hci-vm image show --ids $mktplaceImageID
以下是此指令的範例輸出:
PS C:\Users\azcli> az stack-hci-vm image show --ids $mktplaceImageID Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus { "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/galleryimages/myhci-marketplaceimage", "location": "eastus", "name": "myhci-marketplaceimage", "properties": { "containerName": null, "hyperVGeneration": null, "identifier": null, "imagePath": null, "osType": "Windows", "provisioningState": "Succeeded", "status": null, "version": null }, "resourceGroup": "myhci-rg", "systemData": { "createdAt": "2022-08-05T20:52:38.579764+00:00", "createdBy": "guspinto@microsoft.com", "createdByType": "User", "lastModifiedAt": "2022-08-05T20:52:38.579764+00:00", "lastModifiedBy": "guspinto@microsoft.com", "lastModifiedByType": "User" }, "tags": null, "type": "microsoft.azurestackhci/galleryimages" } PS C:\Users\azcli>
刪除 VM 映像
如果下載因某些原因而失敗,或不再需要映像,您可能會想要刪除 VM 映射。 請遵循下列步驟來刪除 VM 映像。
以系統管理員身分執行 PowerShell。
設定下列參數。
$subscription = "<Subscription ID>" $resource_group = "<Cluster resource group>" $galleryImageName = "<Gallery image name>"
拿掉現有的 VM 映像。 執行以下命令:
az stack-hci-vm image delete --subscription $subscription --resource-group $resource_group --name $mktplaceImage --yes
您可以刪除映像兩種方式:
- 指定名稱和資源群組。
- 指定標識碼。
刪除映射之後,您可以檢查映像是否已移除。 以下是藉由指定名稱和資源群組來刪除影像時的範例輸出。
PS C:\Users\azcli> $subscription = "<Subscription ID>"
PS C:\Users\azcli> $resource_group = "myhci-rg"
PS C:\Users\azcli> $mktplaceImage = "myhci-marketplaceimage"
PS C:\Users\azcli> az stack-hci-vm image delete --name $mktplaceImage --resource-group $resource_group
Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Are you sure you want to perform this operation? (y/n): y
PS C:\Users\azcli> az stack-hci-vm image show --name $mktplaceImage --resource-group $resource_group
Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
ResourceNotFound: The Resource 'Microsoft.AzureStackHCI/marketplacegalleryimages/myhci-marketplaceimage' under resource group 'myhci-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
PS C:\Users\azcli>
下一步
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應