Deploying application to SAP BTP
In this exercise, you will learn how to deploy the application to SAP BTP.
Prerequisites
For the complete execution of current exercise, you must execute the following activities first:
- Execute the following exercises:
- Create your Pay-As-You-Go Account in SAP BTP
- Complete the exercise Implementing CRUD operations in SAP Cloud SDK application
- Complete the exercise Activating the APIs in SAP S/4HANA Cloud
Steps
Checkout the branch tsnestjs_v4.0_deploytocf in SAP Business Application Studio
Open SAP Business Application Studio.
Run the following commands in the terminal. Make sure current working directory is /home/user/projects/cloud-sdk-learning-journey.
Build and push the project to SAP BTP
Build and push the application to SAP BTP by running the following commands in the terminal. Note: You will have to login to your SAP BTP Cloud Foundry account before running the cf commands
Code snippetCopy codecd cloudsdk_bp_ts cf create-service destination lite mydestination cf create-service xsuaa application myxsuaa 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_ts
Note
You 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 applicationVerify that the application is successfully deployed in SAP BTP and the myxsuaa and mydestination services are bound to the application
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
Create a destination named bpdestination in the SAP BTP subaccount with the following values
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 partners
Note
The 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: Review code in the following source files
Code walk-through
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
Optional: Manually create the project
Create or update the following files in the table below
File name Type Contents business-partner.service.ts Path: ~/projects/cloudsdk_bp_ts/src/business-partner
Modified Copy contents from here...
manifest.yml Path: ~/projects/bpstandardvdm
Modified Copy contents from here...
package.json Path: ~/projects/bpstandardvdm
Modified Edit the start:prod script to node dist/src/main