Bearbeiten

Freigeben über


New-AzApiManagementOperation

Creates an API management operation.

Syntax

New-AzApiManagementOperation
   -Context <PsApiManagementContext>
   -ApiId <String>
   [-ApiRevision <String>]
   [-OperationId <String>]
   -Name <String>
   -Method <String>
   -UrlTemplate <String>
   [-Description <String>]
   [-TemplateParameters <PsApiManagementParameter[]>]
   [-Request <PsApiManagementRequest>]
   [-Responses <PsApiManagementResponse[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [<CommonParameters>]

Description

The New-AzApiManagementOperation cmdlet create an API operation.

Examples

Example 1: Create an API management operation

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
New-AzApiManagementOperation -Context $apimContext -ApiId $APIId -OperationId "Operation001" -Name "Operation" -Method "GET" -UrlTemplate "/resource" -Description "Use this operation to get resource"

This command creates an API management operation.

Example 2: Create an API management operation with request and response details

$apimContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
$RID = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementParameter
$RID.Name = "RID"
$RID.Description = "Resource identifier"
$RID.Type = "string"
$Query = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementParameter
$Query.Name = "query"
$Query.Description = "Query string"
$Query.Type = 'string'
$Request = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementRequest
$Request.Description = "Create/update resource request"
$DummyQp = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementParameter
$DummyQp.Name = 'dummy'
$DummyQp.Type = 'string'
$DummyQp.Required = $FALSE
$Request.QueryParameters = @($DummyQp)
$Header = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementParameter
$Header.Name = 'x-custom-header'
$Header.Type = 'string'
$Request.Headers = @($Header)
$RequestRepresentation = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementRepresentation
$RequestRepresentation.ContentType = 'application/json'
$exp = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementParameterExample
$exp.Value = "default"
$exp.Description  = "My default request example"
$exp.ExternalValue  = "https://contoso.com"
$exp.Summary  = "default"
$RequestRepresentation.Examples = @($exp)
$Request.Representations = @($requestRepresentation)
$Response = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementResponse
$Response.StatusCode = 204
New-AzApiManagementOperation -Context $apimContext -ApiId $APIId -OperationId "01234567890" -Name 'Create/update resource' -Method 'PUT' -UrlTemplate '/resource/{rid}?q={query}' -Description "Use this operation to create new or update existing resource" -TemplateParameters @($rid, $query) -Request $Request -Responses @($response)

This example creates an API management operation with request and response details.

Parameters

-ApiId

Specifies the identifier of the API management operation.

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

-ApiRevision

Identifier of API Revision. This parameter is optional. If not specified, the operation will be attached to the currently active api revision.

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

-Context

Specifies the instance of the 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 the description of new API operation.

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

-Method

Specifies the HTTP method of the new API management operation.

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

-Name

Specifies the display name of new API management operation.

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

-OperationId

Specifies the identifier of the API management operation.

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

-Request

Specifies the details of the API management operation.

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

-Responses

Specifies an array of possible API management operation responses.

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

-TemplateParameters

Specifies an array of parameters defined in parameter UrlTemplate. If you do not specify this parameter, a default value will be generated based on the UrlTemplate.

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

-UrlTemplate

Specifies the URL template.

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

Inputs

PsApiManagementContext

String

PsApiManagementParameter[]

PsApiManagementRequest

PsApiManagementResponse[]

Outputs

PsApiManagementOperation