DEV Community

Markus Meyer
Markus Meyer

Posted on • Originally published at markusmeyer.hashnode.dev

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Enter fullscreen mode Exit fullscreen mode

Result

The API and operation is created:

image.png

Top comments (0)