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
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.
After you have tried out the application, you can delete the application and the xsuaa service instance with the following commands (provided order is important):
- cf delete hello-cloud-foundry-srv
- cf delete-service hello-cloud-foundry-auth
Deploy the application using multitarget application (MTA) deployment. MTA extends native vanilla CF workflows with a plugin, refer to this link for more information.
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.tarInstall the CF Multiapps Plugin.cf install-plugin multiapps
Deploy 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 with a URL that you can enter in your browser to visit your application: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" […]After you have tried out the application, you can delete it and also the xsuaa service instance with the following command:cf undeploy hello-cloud-foundry