Business Scenario
In this exercise, you'll deploy your first cloud-native application to the SAP BTP, Cloud Foundry runtime. You'll use both the Cloud Foundry native deployment approach and the multitarget application (MTA) deployment approach.
Exercise Options
You can perform this exercise in two ways:
- Live Environment by using the instructions provided below, you can perform the steps in the SAP BTP Free Tier account.
- Platform Simulation – follow the step-by-step instructions within the simulation by clicking the ‘Start Exercise’ button below.
Note
It's strongly recommended that you perform the steps in the live environment first.Prerequisites
- You have access to an SAP BTP, Cloud Foundry environment and have the necessary permissions to deploy applications into a Cloud Foundry space.
- You have installed the following tools:
Steps
Clone and open the sample application.
Clone the sample application from GitHub
Code Snippet1git clone https://github.com/SAP-samples/cloud-foundry-runtime-learning-journeyOpen the cloned project in your preferred IDE.
Deploy the application using native Cloud Foundry deployment.
Build the project.
This reference application already comes with all necessary files for the deployment. However, you have to build the application for production first:
Code Snippet1cds build --productionThe --production parameter ensures that the cloud deployment-related artifacts are created by cds build.
Log in to your Cloud Foundry instance and target an organization and space.
Use the following command to log in to your Cloud Foundry instance:
Code Snippet1cf loginProvide the API endpoint, which you can find in the SAP BTP cockpit, and your credentials. Once authenticated, target an organization and space by choosing the respective values from the list.
Alternatively, you can also use the following command to target an organization and space:
Code Snippet1cf target -o <organization> -s <space>Push the application to Cloud Foundry.
Use the following command to deploy the application to Cloud Foundry
Code Snippet1cf pushRead more about the deployment via cf-push in the official CAP documentation.
Access the application.
In your Terminal, you'll see the URL of the deployed application. Open the URL in your browser to access the application. Alternatively, you can also navigate into your application that's now deployed inside your Cloud Foundry space on the SAP BTP cockpit and access the application from there.
Deploy the application using multitarget application (MTA) deployment.
Build the project.
This reference application already comes with all necessary files for the deployment. However, you have to build the application for production first:
This will create a mta.tar file in the gen folder. This file contains the deployment artifacts for the MTA deployment.Code Snippet1mbt build -t gen --mtar mta.tarDeploy the application.
Use the following command to deploy the application to Cloud Foundry:
Wait until the process is finished. You can check the status of the deployment of the deployed application in the terminal. Once the deployment is finished, you should see something like this:Code Snippet1cf deploy gen/mta.tarCode Snippet1[…] Application "hello-cloud-foundry-srv" started and available at "[org]-[space]-hello-cloud-foundry-srv.landscape-domain.com" […]