Modifier

Partager via


Get-AzApiManagementSubscription

Gets subscriptions.

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

The Get-AzApiManagementSubscription cmdlet gets a specified subscription, or all subscriptions, if no subscription is specified. Keys will not be included into result details. To get keys, use Get-AzApiManagementSubscriptionKey.

Examples

Example 1: Get all subscriptions

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

This command gets all subscriptions.

Example 2: Get a subscription with a specified ID

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

This command gets a subscription by ID.

Example 3: Get all subscriptions for a user

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

This command gets a user's subscriptions.

Example 4: Get all subscriptions for a product

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

This command gets all subscriptions for the product.

Example 5: Get all subscriptions for a Scope

$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

This command gets all subscriptions which are configured for global api scope

Example 6: Get all subscriptions for a product and user scope

$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

This command gets all subscriptions which are configured for global api scope

Parameters

-Context

Specifies a PsApiManagementContext object.

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

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

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

-ProductId

Specifies a product identifier. If specified, this cmdlet finds all subscriptions by the product identifier.

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

-Scope

Scope identifier. The Scope of the Subscription, whether it is Api Scope /apis/{apiId} or Product Scope /products/{productId} or Global API Scope /apis or Global scope /.

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

-SubscriptionId

Specifies a subscription identifier. If specified, this cmdlet finds subscription by the identifier.

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

-UserId

Specifies a user identifier. If specified, this cmdlet finds all subscriptions by the user identifier.

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

Inputs

PsApiManagementContext

String

Outputs

PsApiManagementSubscription