|
| 1 | +--- |
| 2 | +parser: v2 |
| 3 | +auto_validation: true |
| 4 | +time: 25 |
| 5 | +tags: [ tutorial>beginner, programming-tool>javascript, programming-tool>sapui5, programming-tool>html5, software-product>sap-business-technology-platform, software-product>sap-business-application-studio] |
| 6 | +primary_tag: software-product>sap-btp--cloud-foundry-environment |
| 7 | +author_name: Conrad Bernal |
| 8 | +author_profile: https://github.com/cjbernal |
| 9 | +--- |
| 10 | + |
| 11 | +# Deploy Your First SAPUI5 App |
| 12 | +<!-- description --> Create, build, and deploy an MTA project with an integrated SAPUI5 module to SAP BTP, Cloud Foundry environment |
| 13 | + |
| 14 | +## You will learn |
| 15 | + - How to create an SAPUI5 project |
| 16 | + - How to build a project for Cloud Foundry |
| 17 | + - How to deploy a project to Cloud Foundry |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +### Open the Fiori dev space |
| 22 | + |
| 23 | + |
| 24 | +**Start** a dev space of kind *SAP Fiori* and **open** it by clicking its name. |
| 25 | + |
| 26 | +<!-- border --> |
| 27 | + |
| 28 | +> Have a look at [this tutorial](appstudio-devspace-fiori-create) if you are unsure how to get here or how to create a dev space. |
| 29 | +
|
| 30 | +### Connect to a Cloud Foundry endpoint |
| 31 | + |
| 32 | +Make sure you are connected to a Cloud Foundry endpoint to which you will deploy the SAPUI5 application later. |
| 33 | + |
| 34 | +1. Enter the Cloud Foundry endpoint you want to use. If your environment runs in the EU10-region, this is `https://api.cf.eu10.hana.ondemand.com`. To do so, use the `CF: Login to Cloud Foundry` command. From the menu, select **View** and then **Find Command**. Type `CF: Login` and then select `CF: Login to Cloud Foundry`. Select your endpoint or enter the value for your region and then enter your email and password to proceed. |
| 35 | + |
| 36 | + <!-- border --> |
| 37 | + |
| 38 | +2. Next, you need to select the Cloud Foundry Organization and space you want use. You will see that you are connected to the endpoint once these prompts have been answered. |
| 39 | + |
| 40 | + <!-- border --> |
| 41 | + |
| 42 | + |
| 43 | +### Create a new single-module-project |
| 44 | +This step will guide you through the needed actions to create a project that contains a **single** SAPUI5 application. In case you want to create a project that contains multiple UI modules, please do not follow these instructions and rather create an empty MTA project to which you then add multiple UI modules. |
| 45 | + |
| 46 | + |
| 47 | +1. Click on the link **Start from template** on the *Welcome* screen. |
| 48 | + |
| 49 | + <!-- border --> |
| 50 | + |
| 51 | +2. Select **SAP Fiori freestyle SAPUI5 application** as the template category you want to use and click **Start**. |
| 52 | + |
| 53 | + <!-- border --> |
| 54 | + |
| 55 | +3. Specify the application type **SAPUI5 freestyle** and the floor plan **SAPUI5 Application** and go to the **Next** screen. |
| 56 | + |
| 57 | + <!-- border --> |
| 58 | + |
| 59 | +4. Now you have the option to connect your SAPUI5 application to a data source. As we won't need a data source in this tutorial, select **None** and click **Next**. |
| 60 | + |
| 61 | + <!-- border --> |
| 62 | + |
| 63 | +4. Keep the default view name and click **Next** . |
| 64 | + |
| 65 | + <!-- border --> |
| 66 | + |
| 67 | +4. Name of the module **`sapui5`**, use the application title **`Tutorial`**, define the namespace **`sap.btp`**, and **Add deployment configuration**. Keep the default values for the other parameters and select **Next** to go to the next step. |
| 68 | + |
| 69 | + <!-- border --> |
| 70 | + |
| 71 | +4. Choose **Cloud Foundry** as the target runtime and select **None** for the destination and make sure that **Add application to managed application router** is selected. Then, press **Finish** to create the new project. |
| 72 | + |
| 73 | + <!-- border --> |
| 74 | + |
| 75 | + |
| 76 | +4. Once you see the success message, click **File | Open Workspace...** to open a new dialog. |
| 77 | + |
| 78 | + <!-- border --> |
| 79 | + |
| 80 | + In there, select the generated folder **sapui5** and hit **open** to see the new project. |
| 81 | + |
| 82 | + <!-- border --> |
| 83 | + |
| 84 | + |
| 85 | +### Build the application |
| 86 | + |
| 87 | +Build (aka package) the project to a `mtar` archive to deploy it to Cloud Foundry. |
| 88 | + |
| 89 | +1. Right-click on the `mta.yaml` file and select **Build MTA** to trigger this process. |
| 90 | + |
| 91 | + <!-- border --> |
| 92 | + |
| 93 | +3. Once the build is complete, you can see a message in the log. You can now find the generated `mtar` archive in the project tree under `mta_archives`. |
| 94 | + |
| 95 | + <!-- border --> |
| 96 | + |
| 97 | + |
| 98 | +### Deploy the archive to Cloud Foundry |
| 99 | + |
| 100 | +Now that you created a `mtar` archive, you are all set to deploy the application. |
| 101 | + |
| 102 | +1. Right-click on the `mtar` file and select **Deploy** and **Deploy MTA Archive**. |
| 103 | + |
| 104 | + <!-- border --> |
| 105 | + |
| 106 | +2. Check the console output to make sure the process started. |
| 107 | + |
| 108 | +3. You will see a success message and the URL of the app in the log once the deployment finished. |
| 109 | + |
| 110 | + <!-- border --> |
| 111 | + |
| 112 | +4. You can see the URL of the deployed app when running `cf html5-list -di sap-btp-sapui5-dest-srv -u --runtime launchpad` in a new terminal session. |
| 113 | + |
| 114 | + <!-- border --> |
| 115 | + |
| 116 | + > Use the following command in case you use the Portal service |
| 117 | + > |
| 118 | + > `cf html5-list -di sap-btp-sapui5-destination-service -u --runtime cpp` |
| 119 | + |
| 120 | + |
| 121 | +### Test to the application |
| 122 | + |
| 123 | +1. **Open** the application in your browser. You might need to log in with your SAP ID (the same credentials you use for the SAP BTP Cockpit). |
| 124 | +>There is temporarily a need to update the given URL to view the application. When pasting the URL into your browser, remove `cpp` from your URL and replace it with `launchpad`. |
| 125 | +
|
| 126 | + |
| 127 | +2. See that the sample application consists of a header and an empty page. So you should see something like this: |
| 128 | + |
| 129 | +<!-- border --> |
| 130 | + |
| 131 | + |
| 132 | +Enter the URL of your running application: |
| 133 | + |
0 commit comments