使用 Azure Marketplace 映射建立 Azure Stack HCI VM 映射

適用於:Azure Stack HCI 版本 23H2

本文說明如何使用來自 Azure Marketplace 的來源映射,為您的 Azure Stack HCI 建立虛擬機 (VM) 映射。 您可以使用 Azure 入口網站 或 Azure CLI 建立 VM 映射,然後使用這些 VM 映射在 Azure Stack HCI 上建立 Arc VM。

必要條件

開始之前,請確定下列必要條件已完成。

  • 請務必檢閱並 完成必要條件

  • 如果使用用戶端連線到 Azure Stack HCI 叢集,請參閱 遠端連線到叢集。

從 Azure Marketplace 新增 VM 映像

您可以從 Azure Marketplace 映射建立 VM 映射,然後使用此映射在 Azure Stack HCI 叢集上部署 VM。

請遵循下列步驟,使用 Azure CLI 建立 VM 映射。

登入並設定訂用帳戶

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

  2. 登入。 輸入:

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

    az account set --subscription <Subscription ID>
    

設定一些參數

  1. 為您的訂用帳戶、資源群組、位置、映像的OS類型設定參數。 將中的 < > 參數取代為適當的值。

    $subscription = "<Subscription ID>"
    $resource_group = "<Resource group>"
    $mktplaceImage = "<Marketplace image name>"
    $customLocationName = "<Custom location name>"
    $customLocationID = (az customlocation show --resource-group $resource_group --name "<custom_location_name_for_Azure_Stack_HCI_cluster>" --query id -o tsv)
    $location = "<Location for your Azure Stack HCI cluster>"
    $osType = "<OS of source image>"
    

    下表會說明這些參數:

    參數 描述
    subscription 與您的 Azure Stack HCI 叢集相關聯的訂用帳戶。
    resource-group 您與此映像相關聯的 Azure Stack HCI 叢集資源群組。
    name Azure Stack HCI 叢集的市集映像名稱。
    customLocation Azure Stack HCI 叢集自定義位置的資源標識碼。
    location Azure Stack HCI 叢集的位置。 例如,可以是 eastus
    os-type 與來源映像相關聯的操作系統。 這可以是 Windows 或 Linux。

    以下是範例輸出:

    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> $customLocationName = "myhci-cl"
    PS C:\Users\azcli> $customerLocationID /subscriptions$subscription/resourcegroups/$resource_group/providers/microsoft.extendedlocation/customlocations/$customLocationName
    PS C:\Users\azcli> $location = "eastus"
    PS C:\Users\azcli> $ostype = "Windows"
    

從市集映像建立 VM 映像

  1. 設定其他參數,以指定您想要建立的預定 VM 映像。 您必須包含 Marketplace 映像的供應專案、發行者、SKU 和版本。 將 中的 <> 參數取代為適當的值:

    $publisher = "<Publisher name>"
    $offer = "<OS offer>"
    $sku = "<Image SKU>"
    

    使用下表來尋找可用的市集映像及其屬性值:

    名稱 發行者 供應項目 SKU
    Windows 11 企業版 多會話 + Microsoft 365 microsoftwindowsdesktop office-365 win11-21h2-avd-m365
    win11-23h2-avd-m365
    Windows 10 企業版 多會話 + Microsoft 365 microsoftwindowsdesktop office-365 win10-21h2-avd-m365
    win10-22h2-avd-m365
    Windows 11 專業版 microsoftwindowsdesktop windows-11 win11-21h2-pro
    win11-22h2-pro
    win11-23h2-pro
    Windows 11 企業版 microsoftwindowsdesktop windows-11 win11-21h2-ent
    win11-22h2-ent
    win11-23h2-ent
    Windows 11 企業版的多重工作階段 microsoftwindowsdesktop windows-11 win11-21h2-avd
    win11-22h2-avd
    win11-23h2-avd
    Windows 10/11 Pro microsoftwindowsdesktop windows-10 win10-22h2-pro-g2
    Windows 10 企業版 microsoftwindowsdesktop windows-10 win10-22h2-ent-g2
    Windows 10 企業版的多重工作階段 microsoftwindowsdesktop windows-10 win10-22h2-avd
    Windows Server 2022 Datacenter:Azure Edition microsoftwindowsserver windowsserver 2022-datacenter-azure-edition-hotpatch
    2022-datacenter-azure-edition-core
    2022-datacenter-azure-edition
    Windows Server 2019 microsoftwindowsserver windowsserver 2019-datacenter-gensecond
    2019-datacenter-core-g2
    Windows Server 2022 上的 SQL Server 2022 Enterprise microsoftsqlserver sql2022-ws2022 enterprise-gen2
    standard-gen2

    如果您想要建立 Windows Server 2019 Datacenter 映射,您會有下列參數:

    $publisher = "microsoftwindowsserver" 
    $offer = "windowsserver" 
    $sku = "2019-datacenter-gensecond"
    
  2. 從指定的市集映射開始建立 VM 映射:

    az stack-hci-vm image create --resource-group $resource_group --custom-location $customLocationID --name $mktplaceImage --os-type $ostype --offer $offer --publisher $publisher --sku $sku 
    

以下是範例輸出:

PS C:\Users\azcli> az stack-hci-vm image create --custom-location $cl --name $mktplaceImage --os-type $ostype --resource-group $rg --publisher $publisher --offer $offer --sku $sku 
{ 
  "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/myhci-marketplaceimage", 
\ 
  "location": "eastus", 
  "name": "myhci-marketplaceimage", 
  "properties": { 
    "cloudInitDataSource": null, 
    "containerId": null, 
    "hyperVGeneration": null, 
    "identifier": { 
      "offer": "windowsserver", 
      "publisher": "microsoftwindowsserver", 
      "sku": "2019-datacenter-gensecond" 
    }, 
    "osType": "Windows", 
    "provisioningState": "Succeeded", 
    "status": { 
      "downloadStatus": { 
        "downloadSizeInMb": 10832 
      }, 
      "errorCode": "", 
      "errorMessage": "", 
      "progressPercentage": 100, 
      "provisioningStatus": { 
        "operationId": "13efc468-7473-429f-911b-858c1e6fc1d5*B11A62EE76B08EF194F8293CDD40F7BC71BFB93255D5A99DD11B4167690752D9", 
        "status": "Succeeded" 
      } 
    }, 
    "version": { 
      "name": "17763.6293.240905", 
      "properties": { 
        "storageProfile": { 
          "osDiskImage": { 
            "sizeInMb": 130050 
          } 
        } 
      } 

    } 
  }, 
  "resourceGroup": "myhci-rg", 
  "systemData": { 
    "createdAt": "2024-09-23T18:53:13.734389+00:00", 
    "createdBy": "guspinto@contoso.com", 
    "createdByType": "User", 
    "lastModifiedAt": "2024-09-23T19:06:07.532276+00:00", 
    "lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05", 
    "lastModifiedByType": "Application" 
  }, 

  "tags": null, 
  "type": "microsoft.azurestackhci/marketplacegalleryimages" 
} 

如需此 CLI 命令的詳細資訊,請參閱 az stack-hci-vm 映射

列出 VM 映像

您必須檢視 VM 映射清單,以選擇要管理的映像。

請遵循下列步驟,使用 Azure CLI 列出 VM 映射。

  1. 以系統管理員身分執行 PowerShell。

  2. 設定部分參數。

    $subscription = "<Subscription ID associated with your cluster>"
    $resource_group = "<Resource group name for your cluster>"
    
  3. 列出與您的叢集相關聯的所有 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>

如需此 CLI 命令的詳細資訊,請參閱 az stack-hci-vm image list

檢視 VM 映像內容

您可能想要先檢視 VM 映像的屬性,再使用映像來建立 VM。 請遵循下列步驟來檢視影像屬性:

請遵循下列步驟,使用 Azure CLI 來檢視映像的屬性:

  1. 以系統管理員身分執行 PowerShell。

  2. 設定下列參數。

    $subscription = "<Subscription ID>"
    $resource_group = "<Cluster resource group>"
    $mktplaceImage = "<Marketplace image name>"
    
  3. 您可以透過兩種不同的方式檢視影像屬性:指定識別碼或指定名稱和資源群組。 指定 Marketplace 映射識別符時,請執行下列步驟:

    1. 設定下列參數。

      $mktplaceImageID = "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/galleryimages/myhci-marketplaceimage"
      
    2. 執行下列命令以檢視屬性。

      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 映像

當 Azure Marketplace 中有新的更新映像可用時,Azure Stack HCI 叢集上的 VM 映像會變成過時,且應該更新。 更新作業不是映像的就地更新。 相反地,您可以看到哪些 VM 映射有可用的已更新映像,並選取要更新的映像。 更新之後,建立 VM 映射作業會使用新的更新映像。

若要更新 VM 映射,請使用 Azure 入口網站 中的下列步驟。

  1. 若要查看是否有可用的更新,請從清單檢視中選取 VM 映射。

    顯示 VM 映像更新可供下載的螢幕快照。

    在 [ 概觀] 刀鋒視窗中,您會看到橫幅,其中顯示可供下載的新 VM 映射,如果有的話。 若要更新至新的影像,請選取 箭號圖示

    顯示 VM 映像詳細數據中可供下載之新 VM 映像的螢幕快照。

  2. 檢閱影像詳細數據,然後選取 [ 檢閱並建立]。 根據預設,新映像會使用與上一個映像相同的資源群組和實例詳細數據。

    新映像的名稱會根據上一個映像的名稱遞增。 例如,名為 winServer2022-01 的現有映射會有名為 winServer2022-02 的更新映像。

    此螢幕快照顯示新 VM 映像的 [檢閱和建立] 對話框。

  3. 若要完成作業,請選取 [建立]

    此螢幕快照顯示新 VM 映像的 [建立映像] 對話框。

    建立新的 VM 映射之後,請使用新的映像建立 VM,並確認 VM 是否正常運作。 驗證之後,您可以刪除舊的 VM 映像。

    注意

    在此版本中,如果與該映像相關聯的 VM 正在執行,您就無法刪除 VM 映像。 停止 VM,然後刪除 VM 映像。

刪除 VM 映像

如果下載因為某些原因而失敗,或不再需要映像,您可能會想要刪除 VM 映射。 請遵循下列步驟來刪除 VM 映像。

  1. 以系統管理員身分執行 PowerShell。

  2. 設定以下參數︰

    $subscription = "<Subscription ID>"
    $resource_group = "<Cluster resource group>"
    $mktplaceImage = "<Markeplace image name>"    
    
  3. 拿掉現有的 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>

下一步