Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Chaim_Bendelac
Advisor
Advisor

Introduction

APIs are the cornerstone of modern business ecosystems and are crucial in today’s digital economy. The advent of action-based generative AI, which relies on accessible and well-defined APIs, underscores the importance of composable, API-centric software architectures.

Securing, governing, and managing APIs is essential. API Management has become a recognized discipline, supported by solutions from leading vendors such as SAP, Microsoft, Google, IBM, Salesforce, among others. API Management fosters an ecosystem where authorized developers can access and consume carefully curated and secured collections of APIs.

The essence of API management solutions lies in their ability to regulate access, authenticate and validate API calls through an API Gatewaya proxy solution deployed between API consumers and the service endpoints themselves.

Traditional API Management solutions relied on a single, central API gateway, set up in proximity to the APIs they safeguard. However, this simple architecture is less common today, due to the distributed nature of cloud software applications; customers deploy a growing number of distributed API gateways.

For example, SAP’s API Management solution, a capability of the SAP Integration Suite, provides API gateway functionality as a service available in over twenty regions around the world, as well as self-hosted options for on-premise or private-cloud deployments. This offers customers more flexibility on where to deploy API gateways.

Customers of SAP API Management may, additionally, use API gateways from other vendors and cloud providers like Microsoft Azure. But this presents a new challenge: while there may be multiple API gateways, customers still want to present the managed API information in a unified and centralized API catalog.

To address this, SAP and Microsoft have partnered, sharing programmatic interfaces to facilitate a cohesive API catalog.

This blog targets SAP Integration Suite customers utilizing the SAP API catalog (API Business Hub Enterprise) as their central repository for all APIs, accessible through a developer portal or directly via SAP Build development tools (SAP Build Apps, SAP Build Code, SAP Build Process Automation)

We introduce an extensible API import utility which streamlines and automates the process of importing, registering and publishing additional APIs into the central catalog, such as APIs managed by other vendors, or found in other external catalogs. Here, we focus on Microsoft’s Azure API Management as an information source, but the API import utility can be easily adapted to automate the import of APIs from any other source. For further details, please reach out to us.

A companion blog by our Microsoft friends details how APIs managed by the SAP API gateway can be imported to the Azure API Center, a new central catalog offering from Microsoft.

Automated API import

SAP API Management designates APIs that are not safeguarded by an SAP API gateway as “externally managed” or “unmanaged" APIs. Such APIs can be imported and listed in the API catalog and developer portal, and then optionally further enhanced or managed via API proxies, for instance to ensure that all APIs of the organization share the same security policies and common URL addressing.

While it is straightforward to manually specify a few individual unmanaged APIs and keep these specifications up to date, it becomes a daunting challenge for larger collections of APIs, especially those managed by a non-SAP API gateway.

This blog outlines an extensible API import utility that automates the process of importing, registering and publishing APIs into SAP API Management. The utility employs a “factory” design pattern implemented as an integration with Microsoft’s Azure API Management.

Available as a stand-alone open-source portable Java application, the API import utility can be executed from a desktop, but it is more likely that you will want to incorporate it into a regular workflow or CI/CD pipeline, in order to ensure that the API catalog remains up to date.

Accessing the API Import Utility

Essential tools for using the API Import Utility include:

  • Git
  • Java 11+
  • Maven 3.9+

The code is available here: https://github.com/SAP-samples/api-management-api-import-utility.

Overview

The API import utility was developed by our SAP colleagues Soumen Gosh and Bibin Thomas. It comprises two main components. The api-import code-tree contains the utility’s main class and entry point, in APIImportApplication.java, and the various functions for intefacing with the SAP API Management catalog.

The common interface (IRepositoryService) required by the “factory” in APIDiscoveryFactory.java is simple, and consists of three functions:

public List<API> getListOfApis()

public API getApi(String apiIdName)

public APIDefinition getApiDefinition(API api)

The implementation of these functions for Azure API Management is located in AAMApiRepository.java, in the AAM code-tree. The implementation adheres to the API service documented here: https://learn.microsoft.com/en-us/rest/api/apimanagement/api-management-service.

The following simplified illustration demonstrates the main flow:

chaimbendelac_0-1713942707803.png

The utility fetches the APIs from the Azure API Management and makes them available in SAP API Management as unmanaged APIs. In addition, by default, all imported APIs are added to a new product (a grouping of related APIs) called AAMProduct (you can change this default name in the AAM_product_description.json file in the conf folder).

Building the code

  1. At the root of the code-tree, execute: mvn clean install

    chaimbendelac_1-1713942707804.png

  2. This creates a runtime folder: ./target/app with two subfolders, lib and conf.

 

Preparing Access to Azure API Management

Access to Azure API Management requires an Azure API Management account and the appropriate roles. You will need an Azure Entra ID (formerly known as Azure AD) service principal (for more information, see https://learn.microsoft.com/en-us/purview/create-service-principal-azure).

The command to create a service principal and configure its access to Azure resources is as follows:

az ad sp create-for-rbac --scopes /subscriptions/<subscriptionId> --role Contributor

For more information, see https://learn.microsoft.com/en-us/cli/azure/ad/sp?view=azure-cli-latest#az-ad-sp-create-for-rbac

The command response will be something like this:

chaimbendelac_4-1713943515861.png

Save this response in a file called AAM_connection_details.json, in the conf folder created in the build step above (replace the existing file placeholder).

 

Prepare access to the SAP API management catalog

Accessing SAP API management requires access to an SAP Business Technology Platform (BTP) subaccount, with an installed tenant of the SAP Integration Suite with activated API Management. You will need to generate a service key, which provides trusted access to the public APIs of SAP’s API Management. This process is explained here: https://help.sap.com/docs/integration-suite/sap-integration-suite/api-access-plan-for-api-portal . The resulting service key looks like this:

chaimbendelac_5-1713943655921.png

Save this result as a file called SAP_service_key.json, in the same conf folder created above (replace the existing file placeholder).
 

Running the API import utility

From the app folder, execute:

java -cp api-import.jar;lib/* com.apimgmt.gateway.APIImportApplication

The utility fetches the APIs and makes them available in SAP API Management as unmanaged APIs. In addition, by default, all imported APIs are added into a new product (a grouping of related APIs) called AzureAPIs.

chaimbendelac_2-1713942707809.png

It is up to you to decide if you want to take additional steps, such as adding an API proxy for any of the imported APIs.

Developers browsing the SAP API Management API catalog will see a new product tile representing this product grouping:

chaimbendelac_3-1713942707820.png

Conclusion

The API catalog of SAP API Management serves as a centralized listing for APIs managed across distributed and private-cloud API Gateways. The blog demonstrates how to seamlessly list “externally managed” APIs from various sources, enhancing them to conform to organizational security and compliance standards, and providing a consistent URL schema for all APIs.

The integration of APIs from SAP API Management with those from other gateways or repositories allows for the creation of intricate, distributed application architectures while preserving the vital role of a centralized API catalog.

 

Contacts

soumen.gosh@sap.com, chaim.bendelac@sap.com, mapankra@microsoft.com

1 Comment