Configure API Management with Management API

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.

Background Information:

Users often use the Azure portal to set, change or remove the configurations of API Management. For instance, we import APIs, create products, configure the log analytics, etc.

The whole picture of entire traffic about those operations is:

  • When we make such operations, the Azure Portal will trigger a series call from your local machine through different Azure components until it reaches the API Management service.
  • When we make configuration changing from Azure portal, below call will be propagated from layer to layer:

User -> Azure Resource Manager -> API Management Control Plane (Resource Provider) -> Management API (Management Endpoint of API Management Service)

  • Any accident happens on the intermediate section will cause the configuration update failure.
  • However, API Management provide the feature of opening the management endpoint so we can make the update directly and bypassing the Azure Resource Manager. Then the traffic should be like:

 

User -> Management API (Management Endpoint of API Management Service)

 

Common Scenario:

When import large API definition, Azure resource manager has 2mins of timeout, however, it may need over 2 mins to wait for API Management finishing the API importing.  Therefore, Azure Resource Manager returned 409 error due to the timeout.

In this Scenario, we can call the Management API directly to avoid the similar issue happen.

 

Prerequisites:

Enable the Management API from Azure portal for your API Management Service and generate the SAS token for authentication via API Management REST | Microsoft Docs:

Shuai_Hao_0-1639468081565.png

 

The screen shows the base URL of the Management API, expire date. Then we should generate an Access Token for future use.

Steps:

For instance, we want to list all the API details of an API management Service:

  1. Find the REST API call as your business requirement from Azure API Management REST API | Microsoft Docs

 

Noted: This document’s REST APIs are following the Client -> Azure Resource Manager -> Control Plane -> APIM service, we need to change the endpoint afterwards to bypass the Azure Resource Manager.

 

Steps for getting the target REST API:

  • Expand the Reference -> Current-GA(Generally Available)

Shuai_Hao_1-1639468081572.png

 

  • Find the API format you want.
  1. Copy and paste the URL into Postman, the URL should be like

GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis?api-version=2021-08-01 

  1. Change the management.azure.com into {servicename}.management.azure-api.net:3443, since API Management needs to talk to the service via 3443 port:

After that, the URL should be like:

GET

https:// {servicename}.management.azure-api.net:3443 /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/apis?api-version=2021-08-01

  1. Then in the Authorization Header, we need to add the SAS token generated from the Prerequisites part as the value:

Shuai_Hao_2-1639468081575.png

 

  1. Then we can use the Postman to send the request, the response should be like:

Shuai_Hao_3-1639468257853.png

 

REMEMBER: these articles are REPUBLISHED. Your best bet to get a reply is to follow the link at the top of the post to the ORIGINAL post! BUT you're more than welcome to start discussions here:

This site uses Akismet to reduce spam. Learn how your comment data is processed.