+
+

Module 2 Lab 3 - Securely Deploy the S/4HANA System API

Overview

In lab 2 of this module, we implemented our SAP S/4HANA System API in Anypoint Studio. In this lab, we’re going to deploy the API to CloudHub and setup the management of the API in API Manager. We will learn about the following in this lab:

  • Set the SAP S/4HANA API to be managed in Anypoint API Manager

  • Setup the Auto Discovery property in the Mule application

  • Deploy the API to CloudHub

Step 1: Create a new managed API in API Manager

One of the unique capabilities of the MuleSoft Anypoint Platform is the ability to manage APIs at the application level. In order to do so, we need to add the SAP S/4HANA System API to Anypoint API Manager so we can manage, secure, and monitor the API from one single management console.

1.1 Setup API in Anypoint API Manager

Login to the Anypoint Platform and navigate to API Manager

api mgr1

In API Manager we will now create an instance based on our API specification, an instance is the contract holder of our API. In API Manager, follow these steps:

  • Click on Add API and select Add New API

api mgr2

  • Choose Mule Gateway click on Next

api mgr3

  • Check Select API from Exchange and for the Select API field, start typing the name of the API that you created in Module 2 Lab 1 (e.g. <username>-SAP-S4HANA-sAPI) and select it.

The Asset type, API version, and Asset version fields should be auto-populated. Click on Next.

  • Keep the other fields with their default values and Click on Next.

  • For the Upstream URI field, fill that in with https://localhost:8082 and then click on Next, do a review and after click on Save.

In the next screen, we want to copy the API ID down under API Instance ID. We need this value for the API that we created in Anypoint Studio so it can be registered and recognized by API Manager.

api mgr4

1.2 Setup Autodiscovery in Anypoint Studio

Switch back to Anypoint Studio to the SAP S/4HANA System API project that we created. In the application canvas, click on the Global Elements tab.

api mgr5

Click on Create and type in auto in the Filter field to find the API Autodiscovery element. Double-click on it to open the properties window.

api mgr6

In the properties window, paste your Autodiscovery API ID in the API Id field. For the Flow Name field, select the main flow (e.g. dj-sap-s4hana-sapi-main) and then click on OK to close the window.

api mgr6 5

We have now set the API ID so Anypoint API Manager will recognize our API once deployed to CloudHub. This allows API Manager to secure, manage, and monitor the API.

Step 2: Deploy the API

CloudHub is the iPaaS component of Anypoint Platform - a global, fully-managed, multi-tenanted, secure, and highly available platform for APIs and integrations.

If you want to learn more about CloudHub please visit: https://www.mulesoft.com/platform/saas/cloudhub-ipaas-cloud-based-integration

2.1 (OPTIONAL) Connect Production Environment with Anypoint Studio

These steps are optional if you have already setup the environment client_id and client_secret in Module 1 Lab 3. If so, skip to Step 2.2

In order to deploy managed APIs to CloudHub we need to configure the environment in Anypoint Studio. We need to obtain client_id and client_secret from Anypoint Platform.

Navigate to the Anypoint Platform portal in your browser and open Access Management from the Hamburger Menu. In the left-hand navigation, click Business Group, select your SAP Workshop business group from root, then select Environments from upper tabs and then click on Production

module1 lab3 access1

Click Show to see the client_secret and then leave the window as is and navigate back to Anypoint Studio.

module2 lab3 access2

Switch back to Anypoint Studio and if you’re in Windows OS, click on Window > Preferences.

module2 lab3 access4

Expand the nodes on the left-hand navigation and go to Anypoint Studio > API Manager. In there, copy and paste the Client ID and Client Secret from Anypoint Platform into the Client Id and Client Secret fields under Environment Credentials.

Click on Validate and if it was configured successfully, you should see a green check mark.

Click Apply and Close to close the window.

access5

2.2 Deploy

We can deploy application directly using Anypoint Studio, however in real world scenarios of course the deployment process can be integrated in a CI/CD pipeline for example with Jenkins and Git

Navigate to your application in the Package Explorer and right-click on the root folder and select Anypoint Platform > Deploy to CloudHub

deploy1

A new window will open up. Please select the Sandbox Environment for your deployment

Change the Application Name to something like the following:

Application Name: <username>-sap-s4hana-sapi

CloudHub application names need to be globally unique. If your application name is already taken please modify until a green checkmark is shown.

deploy2

By default “Deployment Target” is set to “Shared Space“ (CloudHub2) so it’s necessary to change it to CloudHub to deploy in the correct Cloud/Region

module2 lab3 deploy

Navigate to the Properties tab and add these properties below.

deploy3

anypoint.platform.config.analytics.agent.enabled=true

anypoint.platform.client_id=

anypoint.platform.client_secret=

In order to fill the values for anypoint.platform.client_id and anypoint.platform.client_secret, follow these steps:

Navigate to the Anypoint Platform portal in your browser and open Access Management from the Hamburger Menu. In the left-hand navigation, click Business Group, select your SAP Workshop business group from root, then select Environments from upper tabs and then click on Sandbox

client credential1

From the new popup window copy Client ID and Client Secret values.

client credential2

Come back to Anypoint Studio and insert these values inside anypoint.platform.client_id and anypoint.platform.client_secret fields.

Click Deploy Application

You can close the window while the application is being deployed. CloudHub will now spin up a dedicated worker instance for your application and your application will have it’s own unique URL.

Summary

Congrats! You’ve created a SAP S/4HANA System API and deployed it to CloudHub where it can be centrally managed by API Manager.

In this lab we covered two topics:

  • Setup the Autodiscovery API ID with your project so it can be managed from API Manager.

  • Deployed your project from Anypoint Studio into CloudHub.

In the next module, we’ll be creating a Process API that leverages the APIs that we’ve created in deployed in Module 1 and 2.

Submit your feedback!
Share your thoughts to help us build the best workshop experience for you!
Take our latest survey!