Skip to content

hpi-epic/btp-tuk

Repository files navigation

BTP Exercise

Goal of the Exercise

This exercise should give a first impression of cloud platforms using the example of the SAP business technology platform (BTP). The SAP BTP is a Platform as a Service (PaaS) offering by SAP that helps you to connect data and business processes of your enterprise. This exercise aims to show you the basic functionalities of the SAP BTP before our block week.

Note: We only use the SAP BTP as an example for cloud platforms. Other cloud platforms such as Google Platform, Microsoft Azure, and Amazon AWS are also capable of enhancing businesses.

Exercise

Many enterprises use a hybrid setup using on-premise and cloud-based software simultaneously. Applications deployed in the cloud often access data persisted in the on-premise systems of a company. Imagine HPI's purchasing department wants to create a cloud application to visualize how much money they spend on every vendor, extending the functionality of their ERP system by using the SAP BTP.

In this exercise, we deploy a small application to a cloud platform that requests data from an on-premise SAP HANA instance. The instance is located at the HPI and only accessible within the network or via a VPN. You will learn how to deploy an application to the SAP BTP, which uses data relying on an on-premise SAP HANA database.

Most cloud applications consist of multiple microservices. The architecture of our exercise is divided into two parts: first, services and applications replying at the HPI, and second your applications deployed on the SAP BTP.

In the following, we briefly describe the functionality of each application/ service of the exercise architecture.

HPI1: SAP HANA The SAP HANA is an in-memory database developed by SAP. The SAP HANA is hosted at vm-reset.eaalab.hpi.uni-potsdam.de. The SAP HANA stores multiple tables from the ERP S/4HANA, which should be familiar to you from exercise 1. Instead of querying the database via TCP, this exercise uses a so-called OData Service to access data via HTTP.

HPI2: OData Service An OData Service is a RESTful API that follows the Open Data Protocol standard. The standard exists in multiple versions. However, we use OData version 2. For your convenience, the OData Service is already implemented as a so-called XS Service directly on the SAP HANA. The API is accessible via http://vm-he4-hana.eaalab.hpi.uni-potsdam.de:8000/odataservice/api.xsodata/. Currently, we have two different collections: purchasing_view and vendors_view. We will use both in our application.

Note: The address is only reachable within the HPI network.

HPI3: SAP Cloud Connector SAP Cloud Connector (SCC) is software that connects the SAP BTP and existing on-premise systems. We have deployed one instance on the same machine as our SAP HANA. This exercise will connect your SAP BTP subaccount to the SCC to access the HPI on-premise SAP HANA. The SCC is accessible at https://vm-he4-hana.eaalab.hpi.uni-potsdam.de:8443/.

BTP1: SvelteKit Application SvelteKit is a framework for building web applications. You will use it to develop an application that queries data from the on-premise SAP HANA and deploy it to the SAP BTP.

BTP2: Connectivity Service SAP BTP's Connectivity service allows you to establish secure and reliable connectivity between your cloud applications and on-premise systems running in isolated networks.

In this exercise, we create one service (provided by SAP) and one application (that you have to program) on the SAP BTP.

Prerequisites

To work on the exercise you need:

Account creation

Before creating services on the cloud platform, we have to create a free account on the SAP BTP.

  1. In case you do not have an SAP BTP Account: Please register for a free trial account.
  2. Login into an account for the SAP BTP
  3. Select US East (VA) - AWS as the region for your trial account.
  4. Wait until your account has been created.
  5. Click on Go To Your Trial Account.

Create Connectivity Service

To access the SAP HANA DB using the SAP Cloud Connector hosted at our research group, you need to create an instance of BTP's Connectivity Service.

  1. After clicking on Go To Your Trial Account, you have to enter your subaccount:
  2. Here, you can use the navigation bar to open the Service Marketplace:
  3. Search for Connectivity Service and click on Create:
  4. Follow the setup (you don't have to enter parameters) and remember the instance name (you will need it later):
  5. Check the status under Instances and Subscriptions (status should be created after a few moments):
  6. Voilà!

Connect Your BTP Account To The On-prom Cloud Connector

As described above, we use the SCC to enable SAP cloud products to connect to the on-premise systems in our landscape. It tunnels the requests.

Please follow these steps to configure the SCC to connect to your SAP BTP account:

Please note that you all share one instance since the SAP Cloud Connector does not support proper user management. Do not delete the subaccounts of your fellow students!

  1. Get your SAP BTP subaccount ID:

    1. In case you do not see your subaccount view: Go to your BTP Trial Account: Click on your subaccount:
    2. Copy/ Remember/ save your subaccount ID:
  2. Connect the SCC instance with your subaccount:

    1. The SCC instance running at EPIC is available here. Please open the website and use the following credentials to log in:
    User Name:  student
    Password:   Student2022
    

    Note: Remember that you have to be in the HPI network or use a VPN to access the instance.

    1. Click add subaccount:
    2. Add a new subaccount by using your BTP credentials to log in. As 'Display name,' use a unique name (e.g., your firstname + lastname). You will need the name in the next step. The subaccount ID is the one you copied/ remembered/ saved before.
    3. In case your display name is not shown in the middle of the website as shown in the next screenshot, click on the small icon in the field 'Subaccount' to switch to your subaccount:
    4. On the left side of the website click on "Cloud To-On-Premise" (it should be right under your choosen display name). Connect the on-premise HANA to the cloud by providing a mapping from the virtual host (vm-he4-hana.eaalab.hpi.uni-potsdam.de) to the internal host (localhost): Back-end type: SAP HANA Protocol: HTTP Change internal host to: localhost, internal port: 8000 Change virtual host to: vm-he4-hana.eaalab.hpi.uni-potsdam.de, virtual port: 8000 Principal type: None Host In Request Header: Use Virtual Host Description: <optional> Click the Check Internal Host checkbox: Click on the newly created entry and press the + button: Add the corresponding ressources by adding the URL path / and save: Back on the SAP BTP, you should now see our SAP HANA under Cloud Connectors:
  3. You did it! We can leave the SCC now and start building our app.

If you encounter this error message:

417 Could not download configuration file. See "Log And Trace Files" and in particular Ijs_trace.log for details. Consult SAP note 2460641 for possible remedies.

... please log in to https://account.sap.com/ and reset your password in the section "Reset Account Password": Try to connect to SCC with the new password you will define in this section. In case your password is locked, just log out and use the "Forgot password?" link

CLI Installation

In most cases, you'll use the command line tool if you interact with cloud platforms since it is way faster than using the UI of the BTP, AWS, Google Platform, or Azure. The BTP uses cloud foundry to deploy applications.

  1. Follow the instructions
  2. Open your terminal and execute the following command to login into your account. You can find the API endpoint in your trial account in section Cloud Foundry Environment.
    > cf login
    API endpoint: https://api.cf.us10.hana.ondemand.com
    Email: <your account mail>
    Password: <your pw>
    

Clone the Git Repository

For your convenience, we prepared a small Svelte application using SvelteKit. You do not need to understand what Svelte is doing. However, it is a fantastic framework for frontend development. Clone the project via git clone and install the dependencies.

> git clone git@github.com:hpi-epic/btp-tuk.git # or HTTPS: https://github.com/hpi-epic/btp-tuk.git
> cd btp-tuk
> npm install

If you want to start the application on your machine, you have to define two environment variables used by the app to connect to the SAP HANA OData Service.

Create a file .env.development with following content:

VITE_ODATA_HPI_HANA_USERNAME=STUDENT2021
VITE_ODATA_HPI_HANA_PASSWORD=Student2021

Now you can serve your application on localhost:3000 by using

> npm run dev

The application should look like that (maybe you see some other data, since we adjusted the content for the exercise)

Deploy Your Application

To deploy your application, you need to create a manifest.yml file in your project's root folder as described here:

applications:
  - name: btp-tuk # Please do not change this name
    path: ./
    buildpacks:
      - nodejs_buildpack
    memory: 256M
    command: node dist/index.js
    random-route: true
    services:
      - <your connectivity service instance name>
    env:
        VITE_ODATA_HPI_HANA_USERNAME: STUDENT2021
        VITE_ODATA_HPI_HANA_PASSWORD: Student2021

Remember to fill in your own connectivity service instance name instead of using <your connectivity service instance name>.

Before deploying the application to the SAP BTP, we first must build the app. Use the following commands to build and push your application to the BTP:

> npm run build
> cf push

In your Cloud Foundry spaces, you can find your deployed applications and access them:

Submission

After finishing this exercise, please add us (Lukas and Tobias) as space developers, so we can access your deployed application. Currently, only your SAP BTP account is allowed to view and change applications and services in your space. To validate your exercise, we require access to your space.

  1. Navigate to your dev space (where you can see your deployed application) and click on "Members".
  2. In the next window, click on "Add Members"
  3. Add lukas.boehme@hpi.de and tobias.wuttke@hpi.de in the field "E-mails" and assign the role "Space Developer" to your space.
  4. Now, we can view your space and check if you deployed the services correctly!

After adding us as space developers, please submit your subaccount's URL using Moodle:

  1. Please go back to your subaccount as described above.
  2. Copy the URL:
  3. Submit the URL in the submission's text field.

The deadline is Wednesday, 3 August 2022, 11:59 PM.

Optional: Clean-up

After the exercise and submitting your results, you can clean up your account and machine. If you are using homebrew on macOS, you can use the following command to remove the Cloud Foundry CLI:

> brew uninstall cloudfoundry/tap/cf-cli@8

Also, you can delete your Cloud Foundry space in your BTP account.