Deploying application to SAP BTP
In this exercise, you will learn how to deploy the application to SAP BTP.
For the complete execution of current exercise, you must execute the following activities first, using SAP Business Application Studio:
- Execute the following exercises:
- Creating your free trial account in SAP BTP
- Setting up the mock server, so that you have the Mock server program available in the
- Run the following commands in a terminal, in case you didn't do it already in previous exercises, to clone the Git repository for the course:Code snippetExpand
cd ~/projects git clone https://github.com/SAP-samples/cloud-sdk-learning-journey.git
- Choose File → Open Folder and open the
Checkout the branch tsnestjs_v4.0_deploytocf in SAP Business Application Studio
Run the following commands in the terminal.Code snippetExpand
cd ~/projects/cloud-sdk-learning-journey git checkout -f tsnestjs_v4.0_deploytocf
Login to Cloud Foundry, using the terminal
Make sure you have the API Endpoint, the email and the Password of your Cloud Foundry account.
In the terminal, runCode snippetExpand
Enter the required information and make sure that login is successful.
Build and push the project to SAP BTP
Build and push the application to SAP BTP by running the following commands in the terminal, replace YOUR_APIKEY_GOES_HERE with your API Key, eventually get your API Key at https://api.sap.com/api/API_BUSINESS_PARTNER/overview):Code snippetExpand
cd cloudsdk_bp_ts cf create-service destination lite mydestination cf create-service xsuaa application myxsuaa npm i npm run build cf push cf set-env cloudsdk_bp_ts DESTINATION_NAME bpdestination cf set-env cloudsdk_bp_ts APIKEY YOUR_APIKEY_GOES_HERE cf restage cloudsdk_bp_tsNoteYou will have to login to your SAP BTP Cloud Foundry account before running the cf commands. Since the application depends on xsuaa and destination service, we need to create an instance of these services before deploying the application
Verify that the application is successfully deployed in SAP BTP and the myxsuaa and mydestination services are bound to the application
Create a destination named bpdestination in the SAP BTP subaccount with the following values
Field Value Name bpdestination Type HTTP URL https://sandbox.api.sap.com/s4hanacloud Proxy Type Internet Authentication NoAuthentication
In the SAP BTP Cockpit, access your Subaccount overview and navigate to Connectivity → Destinations
Create a new destination using the given info, as indicated in the following figure.
Query the Business Partner API of SAP S/4HANA Cloud
Find out the URL of the application. After successful completion of the command cf push, the URL is displayed on the screen
You can find the same URL in the subaccount overview, navigating to Cloud Foundry → Spaces → Dev → cloudsdk_bp_ts → Application Routes
Open a new tab and browse to https://APPLICATION_URL/business-partner. APPLICATION_URL is the URL you copied after executing the cf push command
Verify that you are able to retrieve all the business partnersNoteThe destination values can be modified to connect to an actual SAP S/4HANA Cloud system. Also, the SAP API Business Hub does not support CREATE, UPDATE operations
Optional: code walk-through.
Review code in the following source files:
File name Comments on code changes manifest.yml
Configuration values are as follows...
- Provide basic application information like name, memory, timeout, path etc.
- Specify that the application depends on myxsuaa and mydestination services
requests.http Provides various HTTP requests that can be submitted to query the Business Partner API commands.txt Provides various commands that can be run on the terminal