共用方式為


Get-AzureWebsite

取得目前訂用帳戶中的 Azure 網站。

注意

本文件中參考的 Cmdlet 用於管理使用 Azure Service Manager(ASM) API 的舊版 Azure 資源。 建立新的資源時,不建議使用此舊版 PowerShell 模組,因為 ASM 已排定淘汰。 如需詳細資訊,請參閱 Azure Service Manager 淘汰

Az PowerShell 模組是使用 PowerShell 管理 Azure Resource Manager (ARM) 資源的建議 PowerShell 模組。

語法

Get-AzureWebsite
   [-Name <String>]
   [-Slot <String>]
   [-Profile <AzureSMProfile>]
   [<CommonParameters>]

Description

Get-AzureWebsite Cmdlet 會取得目前訂用帳戶中 Azure 網站的相關信息。

根據預設, Get-AzureWebsite 會取得目前訂用帳戶中的所有 Azure 網站,並傳回 提供網站基本信息的物件。 當您使用 Name 參數時, Get-AzureWebsite 會傳回具有詳細信息的物件,包括組態詳細數據。

目前的訂用帳戶是指定為「目前」的訂用帳戶。若要尋找目前的訂用帳戶,請使用 Get-AzureSubscription Cmdlet 的 Current 參數。 若要變更目前的訂用帳戶,請使用 Select-AzureSubscription Cmdlet。

本主題描述 Microsoft Azure PowerShell 模組 0.8.10 版本中的 Cmdlet。 若要取得您所使用的模組版本,請在 Azure PowerShell 控制台中輸入 (Get-Module -Name Azure).Version

範例

範例 1:取得訂用帳戶中的所有網站

PS C:\> Get-AzureWebsite

此命令會取得目前訂用帳戶中的所有 Azure 網站。

範例 2:依名稱取得網站

PS C:\> Get-AzureWebsite -Name ContosoWeb

此命令會取得 ContosoWeb Azure 網站的詳細資訊,包括組態資訊。 當您使用 Name 參數時, Get-AzureWebsite傳回 SiteWithConfig 物件,其中包含網站的擴充資訊。

範例 3:取得所有網站的詳細資訊

PS C:\> Get-AzureWebsite | ForEach-Object {Get-AzureWebsite -Name $_.Name}

此命令會取得訂用帳戶中所有網站的詳細資訊。 它會使用 Get-AzureWebsite 命令來取得所有網站,然後使用 ForEach-Object Cmdlet 依名稱取得每個網站。

範例 4:取得部署位置的相關信息

PS C:\> Get-AzureWebsite -Name ContosoWeb -Slot Staging

此命令會取得 ContosoWeb 網站的預備部署位置。 部署位置可讓您測試不同版本的 Azure 網站,而不需將其發行給公眾。

範例 5:取得網站實例

PS C:\>(Get-AzureWebsite -Name ContosoWeb).Instances

InstanceId
----------
2d8e712fb8f85d061c30fd793a534e6700a175f9a9ab12ca55cb3b0edfcc10ee
5834916b8cef49249b18187708223a33fbbc4352d33b48369f3166644bdd3445

PS C:\>(Get-AzureWebsite -Name ContosoWeb).Instances.Count
2

此範例中的命令會使用 Azure 網站的 Instances 屬性來取得目前執行中網站實例的相關信息。 Instances 屬性已新增至 Azure 模組 0.8.3 版的 SiteWithConfig 物件。

第一個命令會取得網站目前執行中所有實例的實例標識碼。 第二個命令會取得網站的執行中實例數目。 您可以在任何陣列上使用 Count 屬性。

參數

-Name

取得指定網站的詳細組態資訊。 在訂用帳戶中輸入一個網站的名稱。 根據預設, Get-AzureWebsite 會取得目前訂用帳戶中的所有網站。 Name 值不支援通配符。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

-Profile

指定此 Cmdlet 從中讀取的 Azure 設定檔。 如果您未指定設定檔,此 Cmdlet 會從本機預設配置檔讀取。

類型:AzureSMProfile
Position:Named
預設值:None
必要:False
接受管線輸入:False
接受萬用字元:False

-Slot

取得網站的指定部署位置。 輸入位置名稱,例如「預備」或「生產」。 如需部署位置的詳細資訊,請參閱在 Azure 網站上暫存部署Microsofthttps://azure.microsoft.com/en-us/documentation/articles/web-sites-staged-publishing/. 若要將部署位置新增至現有的 Azure 網站,請使用 Set-AzureWebsite Cmdlet。

類型:String
Position:Named
預設值:None
必要:False
接受管線輸入:True
接受萬用字元:False

輸入

None

您可以透過屬性名稱將輸入管線傳送至此 Cmdlet,但不能依值傳送。

輸出

Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.Site

根據預設,Get-AzureWebsite 會傳回 Site 物件的陣列

Microsoft.WindowsAzure.Commands.Utilities.Websites.Services.WebEntities.SiteWithConfig

當您使用 Name 參數時, Get-AzureWebsite傳回 SiteWithConfig 物件。