Create Azure API Management API Operation with Azure CLI

To create an Azure API Management API or Operation you have to use the current version of Azure CLI:

Install Azure CLI

Check installed version:

az --version

Install or update Azure CLI

Login

Before creating the API you have to be logged in. Maybe you have to select the correct tenant.

az login

Script

Please find the Microsoft documentation here:

az apim api create

az apim api operation create

The script requires an existing API Management:

$resourceGroupName = "eval.datatransformation"
$serviceName = "mm-sample"
$apiId="lorem-ipsum"
$apiDisplayName="Lorem Ipsum"
$apiId="Lorem"
$apiPath="/lorem-ipsum"
$operationPath="/"
$operationDisplayName="Get"
$operationDescription="Gets the data"

az login

# create the API
az apim api create --service-name $serviceName  -g $resourceGroupName --api-id $apiId --path $apiPath --display-name $apiDisplayName

# create the Operation
az apim api operation create --service-name $serviceName  -g $resourceGroupName --api-id $apiId --url-template $operationPath --method "GET" --display-name $operationDisplayName --description $operationDescription

Result

The API and operation is created:

image.png