New-AzureRmApiManagementOperation

Creates an API management operation.

Caution

Because Az PowerShell modules now have all the capabilities of AzureRM PowerShell modules and more, we'll retire AzureRM PowerShell modules on 29 February 2024.

To avoid service interruptions, update your scripts that use AzureRM PowerShell modules to use Az PowerShell modules by 29 February 2024. To automatically update your scripts, follow the quickstart guide.

Syntax

New-AzureRmApiManagementOperation
   -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-AzureRmApiManagementOperation cmdlet create an API operation.

Examples

Example 1: Create an API management operation

PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
PS C:\>New-AzureRmApiManagementOperation -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

PS C:\>$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
PS C:\>$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'
$RequestRepresentation.Sample = '{ "propName": "propValue" }'
$Request.Representations = @($requestRepresentation)
$Response = New-Object -TypeName Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementResponse
$Response.StatusCode = 204
PS C:\>New-AzureRmApiManagementOperation -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
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
Accept pipeline input:True
Accept wildcard characters:False

-Context

Specifies the instance of the PsApiManagementContext object.

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

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with azure.

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Description

Specifies the description of new API operation.

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

-OperationId

Specifies the identifier of the API management operation.

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

-Request

Specifies the details of the API management operation.

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

-UrlTemplate

Specifies the URL template.

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

Inputs

PsApiManagementContext

String

PsApiManagementParameter[]

PsApiManagementRequest

PsApiManagementResponse[]

Outputs

PsApiManagementOperation