Edit

Share via


New-AzApiManagementSubscription

Creates a subscription.

Syntax

OldSubscriptionModel (Default)

New-AzApiManagementSubscription
    -Context <PsApiManagementContext>
    -Name <String>
    -UserId <String>
    -ProductId <String>
    [-SubscriptionId <String>]
    [-PrimaryKey <String>]
    [-SecondaryKey <String>]
    [-AllowTracing]
    [-State <PsApiManagementSubscriptionState>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

NewSubscriptionModel

New-AzApiManagementSubscription
    -Context <PsApiManagementContext>
    -Name <String>
    -Scope <String>
    [-SubscriptionId <String>]
    [-UserId <String>]
    [-PrimaryKey <String>]
    [-SecondaryKey <String>]
    [-AllowTracing]
    [-State <PsApiManagementSubscriptionState>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The New-AzApiManagementSubscription cmdlet creates a subscription.

Examples

Example 1: Subscribe a user to a product

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
New-AzApiManagementSubscription -Context $apimContext -UserId "777" -ProductId "999"

This command subscribes an existing user to a product.

Example 2: Create a subscription for all Api Scope

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
New-AzApiManagementSubscription -Context $apimContext -Scope "/apis" -Name "GlobalApiScope"

Example 3: Create a subscription for Product Scope

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
New-AzApiManagementSubscription -Context $apimContext -Scope "/products/starter" -Name "UnlimitedProductSub"

Parameters

-AllowTracing

Flag which determines whether Tracing can be enabled at the Subscription Level. This is optional parameter and default is $null.

Parameter properties

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

Parameter sets

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

-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

-Name

Specifies the subscription name.

Parameter properties

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

Parameter sets

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

-PrimaryKey

Specifies the subscription primary key. If this parameter is not specified the key is generated automatically. This parameter must be 1 to 256 characters long.

Parameter properties

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

Parameter sets

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

-ProductId

Specifies the ID of the product to which to subscribe.

Parameter properties

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

Parameter sets

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

-Scope

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 /. This parameter is required.

Parameter properties

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

Parameter sets

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

-SecondaryKey

Specifies the subscription secondary key. This parameter is generated automatically if it is not specified. This parameter must be 1 to 256 characters long.

Parameter properties

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

Parameter sets

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

-State

Specifies the subscription state. The default value is $Null.

Parameter properties

Type:

Nullable<T>[PsApiManagementSubscriptionState]

Default value:None
Accepted values:Suspended, Active, Expired, Submitted, Rejected, Cancelled
Supports wildcards:False
DontShow:False

Parameter sets

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

-SubscriptionId

Specifies the subscription ID. This parameter is generated if not specified.

Parameter properties

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

Parameter sets

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

-UserId

Specifies the subscriber ID.

Parameter properties

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

Parameter sets

OldSubscriptionModel
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

Nullable<T>

Outputs

PsApiManagementSubscription