ローカル共有でイメージを使用して Azure Stack HCI VM イメージを作成する

適用対象: Azure Stack HCI バージョン 23H2

この記事では、クラスター上のローカル共有のソース イメージを使用して、Azure Stack HCI 用の仮想マシン (VM) イメージを作成する方法について説明します。 Azure portalまたは Azure CLI を使用して VM イメージを作成し、これらの VM イメージを使用して Azure Stack HCI に Arc VM を作成できます。

前提条件

開始する前に、次の前提条件が満たされていることを確認します。

  • 前提条件を確認して 完了してください。

  • デプロイされ、Arc リソース ブリッジとカスタムの場所を持つ Azure Stack HCI システムにアクセスできます。

    • Azure Stack HCI システム リソースの [概要 > サーバー] ページに移動します。 Azure Arc[接続済み] と表示されていることを確認します。 クラスターのカスタムの場所と Arc リソース ブリッジも表示されます。

      Azure Arc が接続済みであることを示す Azure Stack HCI クラスター リソースの [概要] ページのスクリーンショット。

  • Azure Stack HCI 上のローカル共有内のカスタム イメージの場合は、次の追加の前提条件があります。

    • AZURE Stack HCI クラスター上のローカル共有に VHD/VHDX がアップロードされている必要があります。
    • VHDX イメージは Gen 2 の種類で、セキュア ブートが有効になっている必要があります。
    • VHDX イメージは を使用して sysprep /generalize /shutdown /oobe準備する必要があります。 詳細については、「 Sysprep コマンド ライン オプション」を参照してください。
    • イメージは、クラスター内のすべてのサーバーで使用できるクラスター共有ボリュームに存在する必要があります。 Windows オペレーティング システムと Linux オペレーティング システムの両方がサポートされています。

ローカル共有のイメージから VM イメージを追加する

クラスターのローカル共有内のイメージから始まる 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>"
    $location = "<Location for your Azure Stack HCI cluster>"
    $imageName = <VM image name>
    $imageSourcePath = <path to the source image>
    $osType = "<OS of source image>"
    

    パラメーターについては次の表で説明します。

    パラメーター 説明
    subscription このイメージに関連付ける Azure Stack HCI クラスターのリソース グループ。
    resource_group このイメージに関連付ける Azure Stack HCI クラスターのリソース グループ。
    location Azure Stack HCI クラスターの場所。 たとえば、これは のようになります eastus
    image-path ローカル共有内のイメージから開始して作成された VM イメージの名前。
    : Azure では、キーワード (keyword) 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 イメージを作成する

  1. VM イメージをデプロイするカスタムの場所を選択します。 カスタムの場所は、Azure Stack HCI クラスターのカスタムの場所に対応している必要があります。 Azure Stack HCI クラスターのカスタムの場所 ID を取得します。 次のコマンドを実行します。

    $customLocationID=(az customlocation show --resource-group $resource_group --name "<custom location name for HCI cluster>" --query id -o tsv)
    
  2. Azure Stack HCI クラスターのローカル共有で、指定したイメージから始まる VM イメージを作成します。

    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 イメージを一覧表示するには、次の手順に従います。

  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 クラスターに関連付けられているイメージの対応するセットが一覧表示されます。

    • サブスクリプションのみを指定した場合、コマンドはサブスクリプション内のすべてのイメージを一覧表示します。
    • サブスクリプションとリソース グループの両方を指定した場合、コマンドはリソース グループ内のすべてのイメージを一覧表示します。

    これらのイメージには次のものが含まれます。

    • Marketplace イメージからの VM イメージ。
    • Azure Storage アカウントに存在するカスタム イメージ、またはクラスター上のローカル共有、またはクラスターに接続されているクライアントにあるカスタム イメージ。

出力例を次に示します。

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 を使用してイメージのプロパティを表示するには、次の手順に従います。

  1. PowerShell を管理者として実行します。

  2. 次のパラメーターを設定します。

    $subscription = "<Subscription ID>"
    $resource_group = "<Cluster resource group>"
    $mktplaceImage = "<Marketplace image name>"
    
  3. 画像のプロパティは、ID を指定するか、名前とリソース グループを指定する 2 つの異なる方法で表示できます。 Marketplace イメージ ID を指定するときは、次の手順を実行します。

    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 イメージを削除する

何らかの理由でダウンロードが失敗した場合、またはイメージが不要になった場合は、VM イメージを削除できます。 VM イメージを削除するには、次の手順に従います。

  1. PowerShell を管理者として実行します。

  2. 次のパラメーターを設定します。

    $subscription = "<Subscription ID>"
    $resource_group = "<Cluster resource group>"
    $galleryImageName = "<Gallery image name>"    
    
  3. 既存の VM イメージを削除します。 次のコマンドを実行します。

    az stack-hci-vm image delete --subscription $subscription --resource-group $resource_group --name $mktplaceImage --yes
    

画像は次の 2 つの方法で削除できます。

  • 名前とリソース グループを指定します。
  • ID を指定します。

イメージを削除したら、イメージが削除されたことをチェックできます。 名前とリソース グループを指定してイメージが削除されたときの出力例を次に示します。

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>

次の手順