在 Service Provider Foundation 中匯入圖庫項目

 

適用於: System Center 2012 R2 Orchestrator

本主題適用於使用 Windows Server 適用的 Windows Azure Pack 中的 [VM 雲端]組件庫。 圖庫項目是一種虛擬機器角色,作為標準和可重複使用的成品,主機服務提供者可用其來提供各種供應項目給他們的租用戶。 在 Windows Azure 組件 中,您可以將圖庫項目新增至租用戶所訂閱的計劃。 虛擬機器角色代表一種可調整的虛擬機器階層,可由租用戶使用單一程序進行佈建。 可由虛擬機器角色建立的工作負載範例包括單一虛擬機器、Active Directory 網域控制站、SQL Server 叢集,或 Internet Information Services (IIS) Web 伺服陣列。

如需取得圖庫資源的相關資訊,請參閱 Downloading and Installing Windows Azure Pack Gallery Resource (下載並安裝 Windows Azure Pack 圖庫資源)。 如需建立虛擬機器角色的相關資訊,請參閱 System Center 2012 R2 Virtual Machine Role Authoring Guide (System Center 2012 R2 虛擬機器角色撰寫指南)

Service Provider Foundation 可讓您將圖庫項目從下載的資源套件匯入至 Virtual Machine Manager。 此外,您也可以在 SPFDB 資料庫中追蹤圖庫項目。 然後,您就可以立即在 系統管理員的管理入口網站 的 Windows Azure 組件 中檢視圖庫項目。

您也可以使用 Service Provider Foundation 管理 Web 服務或 Cmdlet 取得圖庫套件、項目或項目的圖示。 這可讓入口網站開發人員建立 UI 元素及功能,在選取圖庫項目上提供租用戶絕佳的體驗。

以下範例顯示如何使用 Windows PowerShell 從套件匯入圖庫項目並使用其中的內容,然後將其移除。

PS C:\> # The first command gets the path to the resource package and stores it in the $Path variable.   
PS C:\> # The second command gets a System.IO.FileStream object of the package.   
PS C:\> # The third command imports the package.  
PS C:\> $Path = "c:\packages\create.resdefpkg"  
PS C:\> $FStream = New-Object IO.FileStream $Path, Open  
PS C:\> Import-SCSPFVMRoleGalleryItem -Package $FStream  
PS C:\>  
PS C:\> # Get an item from the gallery by specifying its name and store it in the $galItem variable.  
PS C:\> $galItem = Get-ScSpfVmRoleGalleryItem -Name 570569955cbfb62b374358b34467020750f65c  
PS C:\>   
PS C:\> # Get the icon object by specifying the required parameters with the variable.   
PS C:\> # The IconFileName parameter is explicitly specified in case the variable has a null value for the icon file name.  
PS C:\> $galItemIcon = Get-SCSPFVMRoleGalleryItemIcon -Name $galItem.Name -Publisher $galItem.Publisher -Version $galItem.Version -IconFilename "contoso.ico"  
PS C:\>  
PS C:\> # Get the package of the gallery and stores it in the $galPkg variable. This cmdlets returns an System.IO.MemoryStream object.  
PS C:\> $galPkg = Get-SCSPFVMRoleGalleryItemPackage -Name 570569955cbfb62b374358b34467020750f65c -Publisher Microsoft -Version 1.0.0.0  
PS C:\>   
PS C:\> # One use of the memory stream of the package is to save it to a file on your computer.  
PS C:\> $fs = New-Object IO.Filestream "c:\@tmp\gal.bin", Create  
PS C:\> $binwriter = New-Object IO.BinaryWriter $fs  
PS C:\> $binwriter.Write($galPkg.ContentStream.ToArray())  
PS C:\> $fs.Close()  
PS C:\> $binwriter.Close()  
PS C:\>  
PS C:\> # Import the package that was just saved, using the PackageFilePath parameter.  
PS C:\> Import-ScSpfVmRoleGalleryItem –PackageFilePath "C:\@tmp\gal.bin"  
  

Service Provider Foundation 為圖庫提供下列 Cmdlet:

  • Get-SCSPFVMRoleGalleryItem

  • Get-SCSPFVMRoleGalleryItemIcon

  • Get-SCSPFVMRoleGalleryItemPackage

  • Import-SCSpfVMRoleGalleryItem

  • Remove-SCSPFVMRoleGalleryItem

  • Set-SCSPFVMRoleGalleryItem

請參閱

Service Provider Foundation 中的入口網站
虛擬機器角色快速入門:逐步解說指南
System Center 2012 R2 虛擬機器角色撰寫指南 - 資源定義套件
在虛擬機器雲端中使用主機庫項目