Edit

Share via


New-AzApiManagementApi

Creates an API.

Syntax

Default (Default)

New-AzApiManagementApi
    -Context <PsApiManagementContext>
    [-ApiId <String>]
    -Name <String>
    [-Description <String>]
    -ServiceUrl <String>
    -Path <String>
    -Protocols <PsApiManagementSchema[]>
    [-AuthorizationServerId <String>]
    [-AuthorizationScope <String>]
    [-OpenIdProviderId <String>]
    [-BearerTokenSendingMethod <String[]>]
    [-SubscriptionKeyHeaderName <String>]
    [-SubscriptionKeyQueryParamName <String>]
    [-ProductIds <String[]>]
    [-SubscriptionRequired]
    [-ApiVersionDescription <String>]
    [-ApiVersionSetId <String>]
    [-ApiVersion <String>]
    [-SourceApiId <String>]
    [-SourceApiRevision <String>]
    [-ApiType <PsApiManagementApiType>]
    [-TermsOfServiceUrl <String>]
    [-ContactName <String>]
    [-ContactUrl <String>]
    [-ContactEmail <String>]
    [-LicenseName <String>]
    [-LicenseUrl <String>]
    [-DefaultProfile <IAzureContextContainer>]
    [<CommonParameters>]

Description

The New-AzApiManagementApi cmdlet creates an Azure API Management API.

Examples

Example 1: Create an API

$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
New-AzApiManagementApi -Context $ApiMgmtContext -Name "Echo api" -ServiceUrl "https://contoso.com/apis/echo" -Protocols @("http", "https") -Path "testapi"

This command creates an API named EchoApi with the specified URL.

Example 2: Create an API by copying all operation, Tags, Products and Policies from echo-api and into an ApiVersionSet

$context = New-AzApiManagementContext -ResourceId /subscriptions/subid/resourceGroups/Api-Default-West-US/providers/Microsoft.ApiManagement/service/contoso
$versionSet = Get-AzApiManagementApiVersionSet -Context $context -ApiVersionSetId "xmsVersionSet"
New-AzApiManagementApi -Context $context -Name "echoapiv4" -Description "Create Echo Api V4" -SubscriptionRequired -ServiceUrl "https://echoapi.cloudapp.net/v4" -Path "echov3" -Protocols @("http", "https") -ApiVersionSetId $versionSet.ApiVersionSetId -SourceApiId "echo-api" -ApiVersion "v4"
ApiId                         : 691b7d410125414a929c108541c60e06
Name                          : echoapiv4
Description                   : Create Echo Api V4
ServiceUrl                    : https://echoapi.cloudapp.net/v4
Path                          : echov3
ApiType                       : http
Protocols                     : {Http, Https}
AuthorizationServerId         :
AuthorizationScope            :
OpenidProviderId              :
BearerTokenSendingMethod      : {}
SubscriptionKeyHeaderName     : Ocp-Apim-Subscription-Key
SubscriptionKeyQueryParamName : subscription-key
ApiRevision                   : 1
ApiVersion                    : v4
IsCurrent                     : True
IsOnline                      : False
SubscriptionRequired          : True
ApiRevisionDescription        :
ApiVersionSetDescription      :
ApiVersionSetId               : /subscriptions/subid/resourceGroups/Api-Default-West-US/providers/Microsoft.ApiManagement/service/contoso/apiVersionSets/xmsVersionSet
Id                            : /subscriptions/subid/resourceGroups/Api-Default-West-US/providers/Microsoft.ApiManagement/service/contoso/apis/691b7d410125414a929c108541c60e06
ResourceGroupName             : Api-Default-West-US
ServiceName                   : contoso

This command creates an API echoapiv3 in ApiVersionSet xmsVersionSet and copies all operation, Tags and Policies from source Api echo-api. It overrides the SubscriptionRequired, ServiceUrl, Path, Protocols

Example 3

Creates an API. (autogenerated)

New-AzApiManagementApi -ApiId '0001' -Context <PsApiManagementContext> -Name 'Echo api' -Path 'echov3' -Protocols Http -ServiceUrl 'https://contoso.com/apis/echo'

Parameters

-ApiId

Specifies the ID of the API to create. If you do not specify this parameter, this cmdlet generates an ID for you.

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

-ApiType

Type of API to create (http, soap, websocket, graphql). This parameter is optional.

Parameter properties

Type:

Nullable<T>[PsApiManagementApiType]

Default value:None
Accepted values:Http, Soap, WebSocket, GraphQL
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

-ApiVersion

Api Version of the Api to create. This parameter is optional.

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

-ApiVersionDescription

Api Version Description. This parameter is optional.

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

-ApiVersionSetId

A resource identifier for the related Api Version Set. This parameter is optional.

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

-AuthorizationScope

Specifies the OAuth operations scope. The default value is $Null.

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

-AuthorizationServerId

Specifies the OAuth authorization server ID. The default value is $Null. You must specify this parameter if AuthorizationScope is 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

-BearerTokenSendingMethod

OpenId authorization server mechanism by which access token is passed to the API. Refer to https://datatracker.ietf.org/doc/html/rfc6749#section-4. This parameter is optional. Default value is $null.

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

-ContactEmail

The email address of the contact person/organization. MUST be in the format of an email address. This parameter is optional.

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

-ContactName

The identifying name of the contact person/organization. This parameter is optional.

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

-ContactUrl

The URL pointing to the contact information. MUST be in the format of a URL. This parameter is optional.

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

-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

-Description

Specifies a description for the web API.

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

-LicenseName

The license name used for the API. This parameter is optional.

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

-LicenseUrl

A URL to the Terms of Service for the API. This parameter is optional.

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

-Name

Specifies the name of the web API. This is the public name of the API as it appears on the developer and admin portals.

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

-OpenIdProviderId

OpenId authorization server identifier. This parameter is optional. Default value is $null. Must be specified if BearerTokenSendingMethods is 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

-Path

Specifies the web API path, which is the last part of the API's public URL and corresponds to the Web API URL suffix field in the admin portal. This URL is used by API consumers to send requests to the web service, and must be one to 400 characters long. The default value is $Null.

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

-ProductIds

Specifies an array of product IDs to which to add the new API.

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

-Protocols

Specifies an array of web API protocols. Valid values are http, https. These are the web protocols over which the API is made available. The default value is $Null.

Parameter properties

Type:

PsApiManagementSchema[]

Default value:None
Accepted values:Http, Https, Ws, Wss
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

-ServiceUrl

Specifies the URL of the web service that exposes the API. This URL is used only by Azure API Management, and is not made public. The URL must be one to 2000 characters long.

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

-SourceApiId

Api identifier of the source API. This parameter is optional.

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

-SourceApiRevision

Api Revision of the source API. This parameter is optional.

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

-SubscriptionKeyHeaderName

Specifies the subscription key header name. The default value is $Null.

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

-SubscriptionKeyQueryParamName

Specifies the subscription key query string parameter name. The default value is $Null.

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

-SubscriptionRequired

Flag to enforce SubscriptionRequired for requests to the Api. This parameter is optional.

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

-TermsOfServiceUrl

A URL to the Terms of Service for the API. This parameter is optional.

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

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

PsApiManagementSchema

String

Outputs

PsApiManagementApi