為您的 Azure Stack Edge Pro GPU 裝置建立自訂 VM 映射

適用于: Yes for Pro GPU SKU Azure Stack Edge Pro - GPU Yes for Pro 2 SKU Azure Stack Edge Pro 2 Yes for Pro R SKU Azure Stack Edge Pro R Yes for Mini R SKU Azure Stack Edge Mini R

若要在 Azure Stack Edge Pro GPU 裝置上部署 VM,您必須能夠建立可在 Azure 中建立 VM 的自訂 VM 映射。 本文說明在適用于 Windows 和 Linux VM 的 Azure 中建立自訂 VM 映射的步驟,並將這些映射下載或複製到Azure 儲存體帳戶。

準備自訂 VM 映射需要工作流程。 針對映射來源,您必須使用任何Azure 支援大小的固定 VHD。 如需 VM 大小選項,請參閱 支援的 VM 大小

必要條件

建立 VM 映射之前,請先完成下列必要條件:

  • 下載 AzCopy 。 AzCopy 可讓您快速將 OS 磁碟複製到Azure 儲存體帳戶。

建立自訂 VM 映射

準備自訂 VM 映射的步驟會因 Windows 或 Linux VM 而有所不同。

執行下列步驟來建立 Windows VM 映射:

  1. 在 Azure 中建立 Windows 虛擬機器。 如需入口網站指示,請參閱 在Azure 入口網站 中建立 Windows 虛擬機器。 如需 PowerShell 指示,請參閱 教學課程:使用 Azure PowerShell 建立和管理 Windows VM。

    虛擬機器可以是第 1 代或第 2 代 VM。 您用來建立 VM 映射的 OS 磁片必須是任何Azure 支援大小的固定大小 VHD。 如需 VM 大小選項,請參閱 支援的 VM 大小

    您可以在 Azure Marketplace 中使用任何 Windows Gen1 或 Gen2 VM 搭配固定大小的 VHD。 如需可運作的 Azure Marketplace 映射清單,請參閱 適用于 Azure Stack Edge 的常用 Azure Marketplace 映射。

  2. 將虛擬機器一般化。 若要將 VM 一般化, 請連線到虛擬機器 、開啟命令提示字元,然後執行下列 sysprep 命令:

    c:\windows\system32\sysprep\sysprep.exe /oobe /generalize /shutdown /mode:vm
    

    重要

    命令完成之後,VM 將會關閉。 請勿重新開機 VM。 重新開機 VM 將會損毀您剛才準備的磁片。

將 OS 磁片下載到儲存體帳戶

若要使用自訂 VM 映射在裝置上部署 VM,您必須將 OS 磁片下載到Azure 儲存體帳戶。 我們建議您使用用於裝置的相同儲存體帳戶。

若要將 VM 的 OS 磁片下載到 Azure 儲存體帳戶,請執行下列步驟:

  1. 在入口網站中 停止 VM。 即使您的 Windows VM 在執行一般化之後 sysprep 已關閉,您也必須執行此動作來解除配置 OS 磁片。

  2. 產生 OS 磁片 的下載 URL,並記下 URL。 根據預設,URL 會在 3600 秒後到期(1 小時)。 您可以視需要增加該時間。

  3. 使用下列其中一種方法,將 VHD 下載到您的Azure 儲存體帳戶:

您現在可以使用此 VHD 在 Azure Stack Edge Pro GPU 裝置上建立和部署 VM。

使用 AzCopy 將 VHD 複製到儲存體帳戶

下列程式說明如何使用 AzCopy 將自訂 VM 映射複製到Azure 儲存體帳戶,讓您可以使用映射在 Azure Stack Edge Pro GPU 裝置上部署 VM。 我們建議您將自訂 VM 映射儲存在您使用的任何現有儲存體帳戶中,其位於與 Azure Stack Edge 相同的區域/訂用帳戶中。

建立容器的目標 URI

AzCopy 需要 目標 URI ,告知將新映射複製到儲存體帳戶的位置。 執行 AzCopy 之前,您會為要複製檔案的 Blob 容器產生共用存取簽章 (SAS) URL。 若要建立目標 URI,您會將檔案名新增至 SAS URL。

若要為備妥的 VHD 建立目標 URI,請執行下列步驟:

  1. 為Azure 儲存體帳戶中的容器產生 SAS URL,請執行下列步驟:

    1. 在Azure 入口網站中,開啟儲存體帳戶,然後選取 [ 容器 ]。 選取 ,然後以滑鼠右鍵按一下您想要使用的 Blob 容器,然後選取 [ 產生 SAS ]。

      Screenshot of the Generate SAS option for a blob container in the Azure portal

    2. 在 [ 產生 SAS] 畫面上,選取 [許可權 ] 中的 [ 讀取 寫入 ]。

      Screenshot of the Generate SAS screen with Read and Write permissions selected

    3. 選取 [ 產生 SAS 權杖和 URL ],然後選取 [ 複製 ] 以複製 Blob SAS URL

      Screenshot of the Generate SAS screen, with options for generating and copying a Blob SAS URL

  2. 若要建立命令的目標 URI azcopy ,請將所需的檔案名新增至 SAS URL。

    Blob SAS URL 的格式如下。

    Graphic of a Blob SAS URL, with container path and place to insert the new filename labeled

    在開始查詢字串的問號前面插入 /<filename>.vhd 檔案名。 副檔名必須是 VHD。

    例如,下列 Blob SAS URL 會將 osdisk.vhd 檔案複製到 mystorageaccount 中的 virtualmachines Blob 容器。

    Graphic of a Blob SAS URL example for a VHD named osdisk

將 VHD 複製到 Blob 容器

若要使用 AzCopy 將 VHD 複製到 Blob 容器,請執行下列步驟:

  1. 如果您尚未完成,請下載 AZCopy

  2. 在 PowerShell 中,流覽至您儲存 azcopy.exe 的目錄,然後執行下列命令:

    .\azcopy copy <source URI> <target URI> --recursive

    其中:

    例如,下列 URI 會將名為 windowsosdisk.vhd 檔案複製到 mystorageaccount 儲存體帳戶中的虛擬機器 Blob 容器:

    .\azcopy copy "https://md-h1rvdq3wwtdp.z24.blob.storage.azure.net/gxs3kpbgjhkr/abcd?sv=2018-03-28&sr=b&si=f86003fc-a231-43b0-baf2-61dd51e3a05a&sig=o5Rj%2BNZSook%2FVNMcuCcwEwsr0i7sy%2F7gIDzak6JhlKg%3D" "https://mystorageaccount.blob.core.windows.net/virtualmachines/osdisk.vhd?sp=rw&st=2021-05-21T16:52:24Z&se=2021-05-22T00:52:24Z&spr=https&sv=2020-02-10&sr=c&sig=PV3Q3zpaQ%2FOLidbQJDKlW9nK%2BJ7PkzYv2Eczxko5k%2Bg%3D" --recursive
    

範例輸出

針對上述範例 AzCopy 命令,下列輸出表示複製已順利完成。

PS C:\azcopy\azcopy_windows_amd64_10.10.0> .\azcopy copy "https://md-h1rvdq3wwtdp.z24.blob.storage.azure.net/gxs3kpbgjhkr/abcd?sv=2018-03-28&sr=b&si=f86003fc-a231-43b0-baf2-61dd51e3a05a&sig=o5Rj%2BNZSook%2FVNMcuCcwEwsr0i7sy%2F7gIDzak6JhlKg%3D" "https://mystorageaccount.blob.core.windows.net/virtualmachines/osdisk.vhd?sp=rw&st=2021-05-21T16:52:24Z&se=2021-05-22T00:52:24Z&spr=https&sv=2020-02-10&sr=c&sig=PV3Q3zpaQ%2FOLidbQJDKlW9nK%2BJ7PkzYv2Eczxko5k%2Bg%3D" --recursive
INFO: Scanning...
INFO: Failed to create one or more destination container(s). Your transfers may still succeed if the container already exists.
INFO: Any empty folders will not be processed, because source and/or destination doesn't have full folder support

Job 783f2177-8317-3e4b-7d2f-697a8f1ab63c has started
Log file is located at: C:\Users\aseuser\.azcopy\783f2177-8317-3e4b-7d2f-697a8f1ab63c.log

INFO: Destination could not accommodate the tier P10. Going ahead with the default tier. In case of service to service transfer, consider setting the flag --s2s-preserve-access-tier=false.
100.0 %, 0 Done, 0 Failed, 1 Pending, 0 Skipped, 1 Total,

Job 783f2177-8317-3e4b-7d2f-697a8f1ab63c summary
Elapsed Time (Minutes): 1.4671
Number of File Transfers: 1
Number of Folder Property Transfers: 0
Total Number of Transfers: 1
Number of Transfers Completed: 1
Number of Transfers Failed: 0
Number of Transfers Skipped: 0
TotalBytesTransferred: 136367309312
Final Job Status: Completed

PS C:\azcopy\azcopy_windows_amd64_10.10.0>

下一步