使用 VMM 和 Windows Azure Pack 建立 VM 範本Create VM templates using VMM and Windows Azure Pack

重要

已不再支援此版本的 Virtual Machine Manager (VMM),建議升級至 VMM 2019This version of Virtual Machine Manager (VMM) has reached the end of support, we recommend you to upgrade to VMM 2019.

身為主機服務提供者,您可以使用 System Center - Virtual Machine Manager (VMM) 搭配 Windows Azure 套件,擴大您向租用戶提供的功能範圍。As a hosting provider, you can use System Center - Virtual Machine Manager (VMM) in combination with Windows Azure Pack to increase the features that you offer to tenants. 您可以建立 VM 角色範本,協助租用戶建立已安裝特定作業系統和應用程式的虛擬機器。To help tenants create virtual machines with specific operating systems and applications already installed, you can create VM role templates. 租用戶可以使用這些範本在服務提供者裝載環境中建立 VM 內部部署。Tenants can use these templates to create VMs on-premises, and in service-provider hosting environments.

開始之前Before you begin

Azure 套件主機庫資源會向租用戶提供使用標準和可重複使用元件的供應項目。Azure Pack Gallery Resources provide tenant offerings using standard and reusable components. VM 角色資源庫可讓您部署 VM。The VM role gallery enables you to deploy VMs. 通常需要兩個套件才能部署一個 VM 角色:Usually you need two packages to deploy a VM role:

  • 資源定義套件 (*.resdefpkg) 部署 VM。A resource definition package (*.resdefpkg) to deploy the VM. 此範本描述要求自助入口網站租用戶提供的 VM 大小、名稱等資訊。VMM 會使用這些參數部署角色。This template describes information asked to self-portal tenants about VM size, name etc. These parameters are used by VMM to deploy the role.
  • 資源延伸模組套件 (*.resextpkg) 在 VM 上安裝應用程式。A resource extension package (*.resextpkg) to install apps on a VM.

每項資源都包含讀我檔案,說明如何準備環境。Each resource contains a Readme file that explains how to prepare your environment.

  1. 下載 Microsoft Web Platform InstallerDownload the Microsoft Web Platform Installer. 您可以使用此項目下載主機庫資源。You use this to download the gallery resources.
  2. 啟動安裝程式,按一下底部的 [選項] 連結,然後在 [自訂摘要] 中輸入連結 https://www.microsoft.com/web/webpi/partners/servicemodels.xml。Start the installer, click the Options link at the bottom, and type the link https://www.microsoft.com/web/webpi/partners/servicemodels.xml into Custom Feeds. 按一下 [新增摘要] > [確定] 。Click Add Feed > OK. 應該會出現 [Service Models] (服務模型) 索引標籤。A Service Models tab should appear.
  3. 在 [Service Models] (服務模型) 索引標籤中,選取 [Gallery Resources] (主機庫資源) 。In the Service Models tab, select Gallery Resources.
  4. 選取想要的資源,然後按一下 [新增] > [安裝] 。Select the resource you want, and click Add > Install.
  5. 如合適即接受授權條款,然後按一下 [繼續] 。Accept the license terms if appropriate, and then click Continue. 下載資源的本機電腦即會開啟該資料夾視窗。A window will be opened for the folder on the local computer where the resource is downloaded.
  6. 資源所附的讀我檔案會指定是否需要其他軟體。The Readme file that accompanies the resource will specify whether additional software is needed. 視需要依照指示操作。Follow the instructions as needed.

將資源延伸模組匯入至程式庫Import resource extensions to the library

如為使用資源延伸模組的主機庫資源,您需要使用 PowerShell 將延伸模組匯入至 VMM 程式庫。For gallery resources that use Resource Extensions, you need to import the extensions into the VMM library, using PowerShell. 本例會示範如何使用程式庫共用 MSSCVMMLibrary 安裝資源延伸模組套件 (MyVMRole.resextpkg),This example shows you how to install a Resource Extension Pack (MyVMRole.resextpkg), with a library shared named MSSCVMMLibrary,

  1. 在命令列中,執行下列命令:At the command line, run the following:
$libraryShare = Get-SCLibraryShare | Where-Object {$_.Name -eq 'MSSCVMMLibrary'}
$resextpkg = $Env:SystemDrive + "\GalleryResources\My-VMRole-Pkg\MyVMRole.resextpkg"
Import-CloudResourceExtension –ResourceExtensionPath $resextpkg -SharePath $libraryShare -AllowUnencryptedTransfer
  1. 請確認已使用下列 Cmdlet 完成匯入:Verify that the import completed with the following cmdlet:
Get-CloudResourceExtension

建立並準備虛擬硬碟Create and prepare a virtual hard disk

若要使用 Sysprep 建立範本,您需要虛擬硬碟檔案,它包含為部署準備就緒的作業系統。To create a template, you need a virtual hard disk file that contains an operating system that's been prepared for deployment, using Sysprep.

指定作業系統Specify the operating system

  1. 當您建立硬碟時,請在作業系統屬性中指定所需的作業系統。When you create the hard disk, specify the required operating system in the Operating System property. 資料磁碟的這個值必須設定為 None。For data disks this value must be set to None.
  2. 使用 VMM 主控台或 PowerShell 設定屬性。Set the property using the VMM console, or PowerShell. 下例會示範如何設定虛擬硬碟 MyVirtualHardDisk 執行 Windows Server 2012 Datacenter。The following example shows how to set the virtual hard disk MyVirtualHardDisk to run Windows Server 2012 Datacenter. 您的 Cmdlet 與以讀我檔案其中一值取代的磁碟名稱。Your cmdlet with replace the disk name with one of the values in the Readme file.
$myVHD = Get-SCVirtualHardDisk | where {$_.Name –eq 'MyVirtualHardDisk.vhd'}
$WS2012Datacenter = Get-SCOperatingSystem | where { $_.name –eq '64-bit edition of Windows Server 2012 Datacenter' }
Set-scvirtualharddisk –virtualharddisk $myVHD –OperatingSystem $WS2012Datacenter

指定名稱和版本Specify the name and release

  1. 您必須設定虛擬硬碟的 Familyname 和 Release 屬性,Windows Azure 套件入口網站才能將虛擬硬碟顯示為此主機庫資源的可用磁碟。The Familyname and Release properties of the virtual hard disk must be set in order for the Windows Azure Pack portal to display the virtual hard disk as an available disk for this Gallery Resource. 這些值會顯示在入口網站的下拉式清單中。These values are shown in the portal drop-down list.

    • Familyname 屬性值應該會指出虛擬硬碟的內容,包括 Windows Server 版次與版本。The Familyname property values should indicate the contents of the virtual hard disk, including the Windows Server release and edition. 主機庫資源的讀我檔案應包含適當的 Familyname 值。The Readme file of the Gallery Resource should include appropriate Familyname values. Release 屬性值必須符合 Windows Azure 的版本設定配置 n.n.n.n。Release property values must conform to the Windows Azure versioning scheme of n.n.n.n. 範例包括 1.0.0.0 和 1.0.0.1。Examples include 1.0.0.0 and 1.0.0.1.
  2. 使用 VMM 主控台或 PowerShell 設定屬性。Set the property using the VMM console, or PowerShell. 下例會示範如何設定 Familyname 為 "Windows Server 2012 Datacenter" 且 Release 屬性為 "1.0.0.0" 的虛擬硬碟。The following example shows how to set the virtual hard disk MyVirtualHardDisk to a Familyname "Windows Server 2012 Datacenter", and the Release property to "1.0.0.0". 您的 Cmdlet 與以讀我檔案其中一值取代的值。Your cmdlet with replace values with one of the values in the Readme file.

$myVHD = Get-SCVirtualHardDisk | where {$_.Name –eq 'MyVirtualHardDisk.vhd'}
$familyName = "Windows Server 2012 DataCenter"
$release = "1.0.0.0"
Set-scvirtualharddisk –virtualharddisk $myVHD –FamilyName $familyName –Release $release

指定標記Specify tags

虛擬機器角色的主機庫項目,會指定作業系統磁碟必須包含的標記,以便使用者佈建虛擬機器時成為可用選項。Virtual Machine Role gallery items specify tags that must be included on an operating system disk for it to be available as an option when a user provisions the virtual machine. 主機庫資源的讀我檔案應包含其所需的標記值。The Readme file of the gallery resource should include the tags that it requires.

  1. 當您建立硬碟時,使用 PowerShell 指定需要的標記。When you create the hard disk, specify the required tags using PowerShell.
  2. 下例會示範如何為虛擬硬碟 MyVirtualHardDisk 設定標記 "WindowsServer2012R1"。The following example shows how to set the tag "WindowsServer2012R1" for the virtual hard disk MyVirtualHardDisk. 您的 Cmdlet 會使用讀我檔案中的值。Your cmdlet use the values in the Readme file.
$myVHD = Get-SCVirtualHardDisk | where {$_.Name –eq 'MyVirtualHardDisk.vhd'}
$tags = $myVHD.Tag
if ( $tags -cnotcontains "WindowsServer2012R1" ) { $tags += @("WindowsServer2012R1") }
Set-scvirtualharddisk –virtualharddisk $myVHD –Tag $tags

將虛擬磁碟新增至程式庫Add the virtual disk to the library

建立虛擬硬碟之後,您必須以您指定的值將它新增至 VMM 程式庫。After you create the virtual hard disk, you must add it to the VMM library with the values you specified. 了解在程式庫中新增檔案型資源。Learn more about adding file-based resources to the library.

匯入資源定義套件Import the Resource Definition packages

當資源延伸和虛擬硬碟放入 VMM 程式庫之後,您就可以使用 Windows Azure 套件的服務管理員入口網站,匯入資源定義套件及發行主機庫項目。After the Resource Extension and virtual hard disk are in the VMM lbirary, you can import the Resource Definition package, and publish the gallery item using the Service Administrator Portal in Windows Azure Pack. 完成這些步驟之後,租用戶就可以使用主機庫項目。After these steps, the gallery item will be available to the tenant.

  • 主機庫資源會包含一或多個資源定義套件檔案。The Gallery Resource will include one or more Resource Definition Package files.
  • 如果包含一個以上,讀我檔案會指定每個會提供的不同設定。If it includes more than one, then the ReadMe file will specify the different configuration that each one will provide.
  1. 開啟服務系統管理員入口網站。Open the Service Admin Portal.
  2. 巡覽至 [VM 雲端] 工作區。Navigate to the VM Clouds workspace.
  3. 按一下 [圖庫] 索引標籤 > [匯入] 。Click the Gallery tab > Import.
  4. 選取並匯入主機庫項目的資源定義套件檔案。Select and import the Resource Definition Package file for the gallery item. 這會是副檔名為 resdefpkg 的檔案。This will be the file with the extension resdefpkg.

請注意,主機庫項目現在應列在 [主機庫] 索引標籤上。The gallery item should now be listed on the Gallery tab.

發佈項目並新增至計劃Publish the item and add to a plan

  1. 在 [主機庫] 索引標籤中,選取您剛才匯入的主機庫項目版本。On the Gallery tab, select the version of the gallery item that you just imported.
  2. 按一下圖庫項目名稱旁的箭號。Click the arrow next to the gallery item name. 確認主機庫項目的詳細資料。Verify the details of the gallery item. 巡覽回先前的頁面,然後按一下 [開放共用] 。Navigate back, and click Make Public.
  3. 選取 [計劃] 工作區,然後選取您想要新增主機庫項目的計劃。Select the Plans workspace, and select the plan to which you want to add the gallery item.
  4. 選取 [虛擬機器雲端] 服務。Select the Virtual Machine Clouds service. 捲動至 [主機庫] 區段,按一下 [新增主機庫項目] 。Scroll to the Gallery section, and click Add Gallery Items. 選取您匯入的主機庫項目,然後按一下 [儲存] 。5 Select the gallery items that you imported, and then click Save

租用戶現在可在選取的計劃中使用虛擬機器角色。The Virtual Machine Role is now available to the tenant as part of the selected plan.

後續步驟Next steps

深入了解佈建 VMLearn about provisioning VMs.