Redigera

Dela via


New-AzApiManagementSubscription

Creates a subscription.

Syntax

New-AzApiManagementSubscription
   -Context <PsApiManagementContext>
   [-SubscriptionId <String>]
   -Name <String>
   -UserId <String>
   -ProductId <String>
   [-PrimaryKey <String>]
   [-SecondaryKey <String>]
   [-AllowTracing]
   [-State <PsApiManagementSubscriptionState>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]
New-AzApiManagementSubscription
   -Context <PsApiManagementContext>
   [-SubscriptionId <String>]
   -Name <String>
   [-UserId <String>]
   -Scope <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.

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

-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

-Name

Specifies the subscription name.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters: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.

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

-ProductId

Specifies the ID of the product to which to subscribe.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters: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.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters: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.

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

-State

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

Type:Nullable<T>[PsApiManagementSubscriptionState]
Accepted values:Suspended, Active, Expired, Submitted, Rejected, Cancelled
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-SubscriptionId

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

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

-UserId

Specifies the subscriber ID.

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

Inputs

PsApiManagementContext

String

Nullable<T>[[Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementSubscriptionState, Microsoft.Azure.PowerShell.Cmdlets.ApiManagement.ServiceManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]

Outputs

PsApiManagementSubscription