Edit

Share via


Get-AzApiManagementSubscription

Gets subscriptions.

Syntax

GetAllSubscriptions (Default)

Get-AzApiManagementSubscription
    -Context <PsApiManagementContext>
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

GetBySubscriptionId

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

GetByProductIdAndUser

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

GetByUserId

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

GetByProductId

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

GetByScope

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.

Parameter properties

Type:PsApiManagementContext
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-DefaultProfile

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

Parameter properties

Type:IAzureContextContainer
Default value:None
Supports wildcards:False
DontShow:False
Aliases:AzContext, AzureRmContext, AzureCredential

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-ProductId

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

GetByProductIdAndUser
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments: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 /.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

GetByScope
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-SubscriptionId

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

GetBySubscriptionId
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-UserId

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

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

GetByProductIdAndUser
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

PsApiManagementContext

String

Outputs

PsApiManagementSubscription