Deploying Your First Application

Objective

After completing this lesson, you will be able to deploy your first application to SAP BTP, Cloud Foundry runtime, using native Cloud Foundry deployment or Multi-Target Application deployment.

Deploy Your First Application

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:

  1. Live Environment by using the instructions provided below, you can perform the steps in the SAP BTP Free Tier account.
  2. 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

Steps

  1. Clone and open the sample application.

    1. Clone the sample application from GitHub.

      Code Snippet
      1
      git clone https://github.com/SAP-samples/cloud-foundry-runtime-learning-journey
    2. Open the cloned project in your preferred IDE.

  2. Deploy the application using native Cloud Foundry deployment.

    1. 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 Snippet
      1
      cds build --production

      The --production parameter ensures that the cloud deployment-related artifacts are created by cds build.

    2. 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 Snippet
      1
      cf login

      Provide 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 Snippet
      1
      cf target -o <organization> -s <space>

    3. Push the application to Cloud Foundry.

      Use the following command to deploy the application to Cloud Foundry

      Code Snippet
      1
      cf push

      Read more about the deployment via cf-push in the official CAP documentation.

    4. 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.

    5. 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):

      1. cf delete hello-cloud-foundry-srv
      2. cf delete-service hello-cloud-foundry-auth
  3. Deploy the application using multitarget application (MTA) deployment. MTA extends native vanilla CF workflows with a plugin, refer to this link for more information.

    1. 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 Snippet
      1
      mbt build -t gen --mtar mta.tar
      This will create a mta.tar file in the gen folder. This file contains the deployment artifacts for the MTA deployment.

    2. Install the CF Multiapps Plugin.cf install-plugin multiapps

    3. Deploy the application.

      Use the following command to deploy the application to Cloud Foundry:

      Code Snippet
      1
      cf deploy gen/mta.tar
      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 Snippet
      1
      […] Application "hello-cloud-foundry-srv" started and available at "[org]-[space]-hello-cloud-foundry-srv.landscape-domain.com" […]

    4. 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