Editar

Partilhar via


New-AzApiManagementApi

Creates an API.

Syntax

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.

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

-ApiType

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

Type:Nullable<T>[PsApiManagementApiType]
Accepted values:Http, Soap, WebSocket, GraphQL
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ApiVersion

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

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

-ApiVersionDescription

Api Version Description. This parameter is optional.

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

-ApiVersionSetId

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

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

-AuthorizationScope

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

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

-AuthorizationServerId

Specifies the OAuth authorization server ID. The default value is $Null. You must specify this parameter if AuthorizationScope is specified.

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

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

-ContactEmail

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

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

-ContactName

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

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

-ContactUrl

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

Type:String
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

-Description

Specifies a description for the web API.

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

-LicenseName

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

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

-LicenseUrl

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

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

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

-OpenIdProviderId

OpenId authorization server identifier. This parameter is optional. Default value is $null. Must be specified if BearerTokenSendingMethods is specified.

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

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

-ProductIds

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

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

Type:PsApiManagementSchema[]
Accepted values:Http, Https, Ws, Wss
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters: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.

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

-SourceApiId

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

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

-SourceApiRevision

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

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

-SubscriptionKeyHeaderName

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

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

-SubscriptionKeyQueryParamName

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

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

-SubscriptionRequired

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

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

-TermsOfServiceUrl

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

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

Inputs

PsApiManagementContext

String

PsApiManagementSchema[]

String[]

Outputs

PsApiManagementApi