|
| 1 | +--- |
| 2 | +title: Deploy Your First SAPUI5 App to Cloud Foundry |
| 3 | +description: Create, build, and deploy an MTA project with an integrated SAPUI5 module. |
| 4 | +auto_validation: true |
| 5 | +time: 25 |
| 6 | +tags: [ tutorial>beginner, topic>javascript, topic>sapui5, topic>html5, products>sap-cloud-platform, products>sap-business-application-studio] |
| 7 | +primary_tag: products>sap-cloud-platform-for-the-cloud-foundry-environment |
| 8 | +--- |
| 9 | + |
| 10 | +## Details |
| 11 | +### You will learn |
| 12 | + - How to create an MTA archive with a UI module |
| 13 | + - How to build a project for Cloud Foundry |
| 14 | + - How to deploy a project to Cloud Foundry |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +[ACCORDION-BEGIN [Step : ](Open the Fiori dev space)] |
| 19 | + |
| 20 | + |
| 21 | +**Start** a dev space of kind *SAP Fiori* and **open** it by clicking its name. |
| 22 | + |
| 23 | +! |
| 24 | + |
| 25 | +> 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. |
| 26 | +
|
| 27 | + |
| 28 | + |
| 29 | +[DONE] |
| 30 | +[ACCORDION-END] |
| 31 | +[ACCORDION-BEGIN [Step : ](Connect to a Cloud Foundry endpoint)] |
| 32 | + |
| 33 | +Make sure you are connected to a Cloud Foundry endpoint to which you will deploy the SAPUI5 application later. |
| 34 | + |
| 35 | +1. Click on the bottom-left corner of the screen to start the connection flow. |
| 36 | + |
| 37 | + ! |
| 38 | + |
| 39 | +2. 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`. Enter your email and your password to proceed. |
| 40 | + |
| 41 | + ! |
| 42 | + |
| 43 | +3. 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. |
| 44 | + |
| 45 | + ! |
| 46 | + |
| 47 | + |
| 48 | +[DONE] |
| 49 | +[ACCORDION-END] |
| 50 | + |
| 51 | +[ACCORDION-BEGIN [Step : ](Create a new project)] |
| 52 | +1. Click on the link **New project From template** on the *Welcome* screen. |
| 53 | + |
| 54 | + ! |
| 55 | + |
| 56 | +2. Select **Fiori Project** as the template category you want to use and click **Next**. |
| 57 | + |
| 58 | + ! |
| 59 | + |
| 60 | +3. Specify the target environment ( **Cloud Foundry** ) and the template ( **SAPUI5 Application** ) and go to the **Next** screen. |
| 61 | + |
| 62 | + ! |
| 63 | + |
| 64 | +4. Name the project **`tutorial`** and proceed by clicking **Next**. |
| 65 | + |
| 66 | + ! |
| 67 | + |
| 68 | +4. Choose **Standalone Approuter** for the runtime and click **Next**. |
| 69 | + |
| 70 | + ! |
| 71 | + |
| 72 | +4. Name of the module **`webapp`** and the namespace **`sap.cp`** and turn authentication off. Go to the **Next** screen. |
| 73 | + |
| 74 | + ! |
| 75 | + |
| 76 | +4. Keep the default view name and go for no data service on this screen. Click **Next** to create the new project. |
| 77 | + |
| 78 | + ! |
| 79 | + |
| 80 | + |
| 81 | +4. Once the project has been created, the Business Application Studio will prompt you to open the project in a new workspace. Click **Open in New Workspace**. |
| 82 | + |
| 83 | + |
| 84 | + ! |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +[DONE] |
| 90 | +[ACCORDION-END] |
| 91 | +[ACCORDION-BEGIN [Step : ](Redirect incoming traffic to the SAPUI5 app)] |
| 92 | + |
| 93 | + |
| 94 | +The generated code comes ready-to-deploy. By default, the web app will be available at `https://<approuter-url>/<app/id>` and the application router will not redirect traffic that hits the root URL. In this step, you will change this. |
| 95 | + |
| 96 | +1. **Open** the file `webapp/webapp/manifest.json` and find the property `sap.app>id`. The value of this property should be `sap.cp.webapp` but can vary depending on the names you choose in the previous step. |
| 97 | + |
| 98 | + ! |
| 99 | + |
| 100 | +2. **Open** the file `tutorial-approuter/xs-app.json` and add a new property to define the redirect. |
| 101 | + |
| 102 | + ! |
| 103 | + |
| 104 | + |
| 105 | +[DONE] |
| 106 | +[ACCORDION-END] |
| 107 | +[ACCORDION-BEGIN [Step : ](Build the application)] |
| 108 | + |
| 109 | +Build (aka package) the project to a `mtar` archive to deploy it to Cloud Foundry. |
| 110 | + |
| 111 | +1. Right-click on the `mta.yaml` file and select **Build MTA** to trigger this process. |
| 112 | + |
| 113 | + ! |
| 114 | + |
| 115 | +2. Check the console output to make sure the process started. |
| 116 | + |
| 117 | + ! |
| 118 | + |
| 119 | +3. Once the build is complete, you can see a message in the log. You can find the generated `mtar` archive in the project tree now. |
| 120 | + |
| 121 | + |
| 122 | + |
| 123 | +[DONE] |
| 124 | +[ACCORDION-END] |
| 125 | +[ACCORDION-BEGIN [Step : ](Deploy the archive to Cloud Foundry)] |
| 126 | + |
| 127 | +Now that you created a `mtar` archive, you are all set to deploy the application. |
| 128 | + |
| 129 | +1. Right-click on the `mtar` file and select **Deploy** and **Deploy MTA Archive**. |
| 130 | + |
| 131 | + ! |
| 132 | + |
| 133 | +2. Check the console output to make sure the process started. |
| 134 | + |
| 135 | +3. You will see a success message and the URL of the app in the log once the deployment finished. Open this URL in your browser to start the application. |
| 136 | + |
| 137 | + ! |
| 138 | + |
| 139 | +> You can also see the URL of the deployed app when running `cf apps` in a new terminal session. |
| 140 | + ! |
| 141 | + |
| 142 | +[DONE] |
| 143 | +[ACCORDION-END] |
| 144 | + |
| 145 | +[ACCORDION-BEGIN [Step : ](Test to the application)] |
| 146 | + |
| 147 | +1. **Open** the started application in your browser. You might need to log in with your SAP ID (the same credentials you use for the SAP Cloud Platform Cockpit). |
| 148 | + |
| 149 | + |
| 150 | +2. See that the sample application consists of a header and an empty page. So you should see something like this: |
| 151 | + |
| 152 | +! |
| 153 | + |
| 154 | + |
| 155 | +Enter the URL of your running application: |
| 156 | + |
| 157 | +[VALIDATE_1] |
| 158 | +[ACCORDION-END] |
0 commit comments