Get-AzApiManagementSubscription

取得訂用帳戶。

Syntax

Get-AzApiManagementSubscription
   -Context <PsApiManagementContext>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzApiManagementSubscription
   -Context <PsApiManagementContext>
   [-SubscriptionId <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzApiManagementSubscription
   -Context <PsApiManagementContext>
   -UserId <String>
   -ProductId <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzApiManagementSubscription
   -Context <PsApiManagementContext>
   [-UserId <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzApiManagementSubscription
   -Context <PsApiManagementContext>
   [-ProductId <String>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
Get-AzApiManagementSubscription
   -Context <PsApiManagementContext>
   -Scope <String>
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

如果未指定任何訂用帳戶,Get-AzApiManagementSubscription Cmdlet 會取得指定的訂用帳戶,或所有訂用帳戶。 金鑰不會包含在結果詳細數據中。 若要取得密鑰,請使用 Get-AzApiManagementSubscriptionKey

範例

範例 1:取得所有訂用帳戶

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-East-US" -ServiceName "contoso"
Get-AzApiManagementSubscription -Context $apimContext

此命令會取得所有訂用帳戶。

範例 2:取得具有指定標識碼的訂用帳戶

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-East-US" -ServiceName "contoso"
Get-AzApiManagementSubscription -Context $apimContext -SubscriptionId "0123456789"

此命令會依標識碼取得訂用帳戶。

範例 3:取得使用者的所有訂用帳戶

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-East-US" -ServiceName "contoso"
Get-AzApiManagementSubscription -Context $apimContext -UserId "777"

此命令會取得用戶的訂用帳戶。

範例 4:取得產品的所有訂用帳戶

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-East-US" -ServiceName "contoso"
Get-AzApiManagementSubscription -Context $apimContext -ProductId "999"

此命令會取得產品的所有訂用帳戶。

範例 5:取得範圍的所有訂用帳戶

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-East-US" -ServiceName "contoso"
Get-AzApiManagementSubscription -Context $apimContext -Scope "/apis"

SubscriptionId    : allApScope
UserId            :
OwnerId           :
ProductId         :
Scope             : /subscriptions/subid/resourceGroups/Api-Default-East-US/providers/Microsoft.ApiManagement/service/contoso/apis
Name              : All Api Scope
State             : Active
CreatedDate       : 6/18/2019 5:53:49 PM
StartDate         :
ExpirationDate    :
EndDate           :
NotificationDate  :
PrimaryKey        :
SecondaryKey      :
StateComment      :
AllowTracing      : False
Id                : /subscriptions/subid/resourceGroups/Api-Default-East-US/providers/Microsoft.ApiManagement/service/contoso/subscriptions/allApScope
ResourceGroupName : Api-Default-East-US
ServiceName       : contoso

此命令會取得針對全域 API 範圍設定的所有訂用帳戶

範例 6:取得產品和用戶範圍的所有訂用帳戶

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-East-US" -ServiceName "contoso"
Get-AzApiManagementSubscription -Context $apimContext -ProductId 59b872f28a82740f547e6270 -UserId 1

SubscriptionId    : 59b872f38a82741750c8da56
UserId            : 1
OwnerId           : /subscriptions/subid/resourceGroups/Api-Default-East-US/providers/Microsoft.ApiManagement/service/contoso/users/1
ProductId         : 59b872f28a82740f547e6270
Scope             : /subscriptions/subid/resourceGroups/Api-Default-East-US/providers/Microsoft.ApiManagement/service/contoso/products/59b872f28a82740f547e6270
Name              :
State             : Active
CreatedDate       : 9/12/2017 11:51:15 PM
StartDate         : 9/12/2017 12:00:00 AM
ExpirationDate    :
EndDate           :
NotificationDate  :
PrimaryKey        :
SecondaryKey      :
StateComment      :
AllowTracing      : True
Id                : /subscriptions/subid/resourceGroups/Api-Default-East-US/providers/Microsoft.ApiManagement/service/contoso/subscriptions/59b872f38a82741750c8da56
ResourceGroupName : Api-Default-East-US
ServiceName       : contoso

此命令會取得針對全域 API 範圍設定的所有訂用帳戶

參數

-Context

指定 PsApiManagementContext 物件。

Type:PsApiManagementContext
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

用於與 azure 通訊的認證、帳戶、租用戶和訂用帳戶。

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ProductId

指定產品識別碼。 如果指定,此 Cmdlet 會依產品標識碼尋找所有訂用帳戶。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Scope

範圍標識碼。 訂用帳戶的範圍,無論是 Api 範圍 /apis/{apiId} 或產品範圍 /products/{productId} 或全域 API 範圍 /apis 或全域範圍 /。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-SubscriptionId

指定訂用帳戶標識碼。 如果指定,此 Cmdlet 會依標識碼尋找訂用帳戶。

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-UserId

指定使用者識別碼。 如果指定,此 Cmdlet 會依使用者標識碼尋找所有訂用帳戶。

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

輸入

PsApiManagementContext

String

輸出

PsApiManagementSubscription