Performing a Manual Deployment

Objectives
After completing this lesson, you will be able to:

After completing this lesson, you will be able to:

  • Perform a manual deployment

Deploy SAP BTP Cloud Foundry Applications Manually

Usage Scenario

You will deploy your CAP application into the Cloud Foundry environment of the SAP Business Technology Platform manually using:

  • The Cloud Foundry Command Line Interface (CLI).
  • A Multi-target application (MTA) file. You will also replace the in-memory SQLite database with an SAP HANA Cloud instance to store the application data.

Exercise Options

You can perform this exercise in two ways:

  1. Live Environment – using the instructions provided below, you can perform the tasks in the SAP BTP Free Tier account.
  2. Platform Simulation – follow the step-by-step instructions within the simulation.
Note
We are strongly recommending first performing the tasks in the live environment.

Live Environment

In this exercise, you will perform the following steps:

  • Set Up SAP HANA Cloud Instance.
  • Prepare the Project for Production.
  • Inspect Deployed Apps in SAP BTP Cockpit.

Prerequisite

Before starting this exercise, make sure you have added an external service.

Result

You have now successfully deployed your multi-target application to Cloud Foundry on SAP BTP.

Task 1: Set Up SAP HANA Cloud Instance

Steps

  1. Set Up SAP HANA Cloud Instance.

    First, you need to set up the SAP HANA Cloud instance in your BTP account.

    Note
    Note that screens in the cloud may change. So, the screenshots in this solution may differ slightly from the screens in your training system.
    1. Enter the subaccount that you are using for this course.

    2. Enter the space that you are using for this course (for example, the dev space).

    3. In the navigation on the left, choose SAP HANA Cloud.

    4. Select Create and choose SAP HANA database.

      You will be redirected into SAP HANA Cloud Central for the instance creation. When being asked to authenticate, use your SAP Account user credentials that you used to create your SAP BTP account. You should then see the following dialog. Select SAP HANA Cloud and click on Next Step.

    5. The Location settings should point to your Cloud Foundry org and space.

      Use the following settings for the remaining fields:

      KeyValue
      Instance Namehana-cloud
      DescriptionHANA Cloud used for exercises
      Administrator Passwordcreate a password according to the password policy

    6. Click on the Next Step button.

    7. The default parameters for your SAP HANA Cloud database display. Select the Next Step button.

    8. You have to select an availability zone for the SAP HANA Cloud Database. Confirm the default settings by clicking on Next Step.

    9. You will see the SAP HANA Database Advanced Settings dialog. Here, you can allow or deny certain IP addresses for connection to your database instance.

      You also find a setting to connect the database to remote sources via the Cloud Connector. This is especially useful in replication use cases, where you need to replicate data from on-premise sources to your SAP HANA Cloud instance. In our use case, this setting is not required.

    10. Select the Allow all IP addresses option, then select the Review and Create button.

    11. The Review page displays. Review the values and choose theCreate Instance button.

    12. The overview of your database instances appears. There should be a new entry for your hana-cloud instance with StatusCREATING.

      The process will take several minutes to complete. Once done, the Status should switch to RUNNING. Use the Refresh button to update the status. Your SAP HANA Cloud instance is now ready to be used.

    13. Return to your BTP subaccount and to your cloud foundry space and select SAP HANA Cloud.

    14. Your hana-cloud instance displays in the SAP HANA Database Instances overview.

Task 2: Prepare the Project for Production

Steps

  1. Prepare the Project for Production.

    1. Configure SAP HANA Cloud in the project.

      While we used SQLite as a low-cost stand-in during development, we’re going to use a managed SAP HANA database for production:

      Code snippet
      cds add hana --for production
      Copy code

      Use the displayed code.

    2. Enable XSUAA-based Authentication.

      Code snippet
      cds add xsuaa --for production
      Copy code
      This will also generate a xs-security.jsonfile, which has to be configured. This file stores the configuration for the xsuaa-service on SAP BTP.

    3. Generate the xs-security.jsonfile content.

      Code snippet
      cds compile srv/ --to xsuaa > xs-security.json
      Copy code
    4. Create the MTA descriptor file for MTA-Based deployment.

      This will generate the mta.yaml file, which contains all the services for the multi target application (MTA) deployment.

      Code snippet
      cds add mta
      Copy code

    5. Open the mta.yaml file and specify the custom domain in the redirect-uris parameter for the xsuaa resource:

      Code snippet
      
      oauth2-configuration: # <-- add this
       redirect-uris:
       # example: - https://risk-management-approuter.cfapps.eu10-004.hana.ondemand.com/login/callback
       - https:///login/callback
      
      Copy code

      It should be added to the config of the resource definition. At the end it schould look like:

      Code snippet
      resources:
      
      
      - name: risk-management-auth
        type: org.cloudfoundry.managed-service
        parameters:
          service: xsuaa
          service-plan: application
          path: ./xs-security.json
          config:
            # [...]
            oauth2-configuration: # <-- add this
              redirect-uris:
              # example: - https://risk-management-approuter.cfapps.eu10-004.hana.ondemand.com/login/callback
              - https:///login/callback
      
      Copy code
    6. Add the managed approuter as gateway to the project.

      This will set up the app router, which acts as a single point-of-entry gateway to route requests to our app. In particular, it ensures user login and authentication in combination with XSUAA. This command will also add the approuter module to the mta.yamlfile.

      Code snippet
      cds add approuter --for production
      Copy code

    7. Configure the approuter by opening the xs-app.jsonfile in the app/directory of your project.

      Code snippet
      
      {
        "welcomeFile": "/app/risks/webapp/index.html",
        "routes": [
          {
            "source": "^/app/(.*)$",
            "localDir": "./",
            "target": "$1"
          },
          {
            "source": "^/service/(.*)$",
            "destination": "srv-api"
          }
        ]
      }
      
      Copy code

      This will set up the routing to the SAP Fiori Elements file and to the backend service.

      Note
      The previous steps are required only once in a project’s lifetime. With that done, you can repeatedly deploy the application.
    8. Freeze Dependencies

      Deployed applications should freeze all their dependencies, including transient ones.

      Code snippet
      npm update --package-lock-only
      Copy code
      Note
      Note: You should regularly update your:package-lock.jsonto consume latest versions and bug fixes. Do so by running this command again, for example, each time you deploy a new version of your application.
    9. Build MTA-project.

      The following command will build the project based on the mta.yamlfile. The output will be stored in the gen/folder.

      Code snippet
      mbt build -t gen --mtar mta.tar
      Copy code

    10. Deploy the generated MTA-project.

      Odds are, that you have to log in to your Cloud Foundry org and space first. For this run cf loginfirst and provide the necessary information.

      Code snippet
      cf deploy gen/mta.tar
      Copy code
      This process can take some minutes and finally creates a log output like this:
      Code snippet
      [...] 
      Application "risk-management" started and available at "[org]-[space]-risk-management.landscape-domain.com"
       [...]
      
      Copy code

Task 3: Inspect Deployed Apps in SAP BTP Cockpit

Steps

  1. Inspect Deployed Apps in SAP BTP Cockpit.

    In this step you will inspect the deployed risk-management application. Compared to the deployment procedure you performed in the previous steps, this will save you a lot of manual work in the long run.

    1. Visit the "Applications" section in your SAP BTP cockpit to see the deployed apps.

      Deployed Applications
    2. Click on the risk-management application and then on the application route.

      Application route
    3. You will notice that the external data can't be retrieved, since the API key was not set yet. For this, go back one step and select the risk-management-srv application. Click on User Provided Variables in the navigation bar on the left side and set the API key.

      Set API key
    4. Now, click on Overview on the left side and then restart the application to ensure that this variable change take effect.

    5. Now review the app again, by opening up the risk-managementapplication.

    Platform Simulation

    Click on the Start button below to open a simulation of the platform. Then follow the step-by-step instructions to deploy a CAP Application.

Reference Links: Performing a Manual Deployment

For your convenience this section contains the external references in this lesson.

If links are used multiple times within the text, only the first location is mentioned in the reference table.

Ref#SectionContext text fragmentBrief descriptionLink
1Set Up SAP HANA Cloud Trial InstanceOpen your SAP BTP Trial Account CockpitOpen SAP BTP cockpithttps://cockpit.hanatrial.ondemand.com/trial/#/globalaccount
2Manual Deployment Using a "Multi Target Application" (MTA) File(MTA) file for deploymentSAP Help Portal, Create the MTA...https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.05/en-US/ebb42efc880c4276a5f2294063fae0c3.html
3Manual Deployment Using a "Multi Target Application" (MTA) Fileit supports blue-green deployment.SAP Help Portal, Blue-Green Deployment Strategyhttps://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/7c83810c31d842938cbc39c135a2d99f.html
4Generate MTA Deployment Descriptor (mta.yaml)MTA deployment is described in the MTA Deployment DescriptorSAP Help Portal, MTA deploymenthttps://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.03/en-US/33548a721e6548688605049792d55295.html

Save progress to your learning plan by logging in or creating an account

Login or Register