在SPF中匯入資源庫專案

重要

此版本的 Service Provider Foundation (SPF) 已終止支援;我們建議您 升級至SPF 2022

資源庫專案是作為標準和可重複使用成品的 VM 角色。 裝載服務提供者可以使用這些專案來提供供應專案給其租使用者。 在 Microsoft Azure Pack 中,您可以將資源庫專案新增至租用戶訂用帳戶方案。 虛擬機器角色代表一種可調整的虛擬機器階層,可由租用戶使用單一程序進行佈建。 可由虛擬機器角色建立的工作負載範例包括單一虛擬機器、Active Directory 網域控制站、SQL Server 叢集,或 Internet Information Services (IIS) Web 伺服陣列。 深入了解 資源庫資源。

在 System Center - Service Provider Foundation (SPF) 中,您可以從下載的資源套件將資源庫專案匯入 System Center - Virtual Machine Manager (VMM) 。 資源庫專案會在SPFDB資料庫中追蹤。 然後,資源庫專案會立即可供 Microsoft Azure Pack 系統管理員在管理入口網站中檢視。

SPF 為資源庫提供下列 Cmdlet:

  • Get-SCSPFVMRoleGalleryItem

  • Get-SCSPFVMRoleGalleryItemIcon

  • Get-SCSPFVMRoleGalleryItemPackage

  • Import-SCSpfVMRoleGalleryItem

  • Remove-SCSPFVMRoleGalleryItem

  • Set-SCSPFVMRoleGalleryItem

您可以使用 SPF 管理員 Web 服務或 Cmdlet 來取得專案的連結庫套件、專案或圖示。 入口網站開發人員可以建立UI元素和功能,以提供租用戶選取資源庫專案的吸引人的體驗。

下列範例示範如何使用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"