In this exercise you'll learn how easy it is to deploy your application directly from SAP Business Application Studio to a Cloud Foundry environment hosted by SAP Cloud Platform.
First of all, you need to create the space in your Cloud Foundry environment to host your newly created UI5 application.
-
Open the SAP Cloud Platform Trial by opening https://cockpit.hanatrial.ondemand.com/cockpit/#/home/trial in a new browser tab and click Enter Your Trial Account.
-
You're redirected to your personal SAP Cloud Platform Cockpit where your subaccounts are listed. Click on the prefered subaccount, e.g. trial.
-
Click the menu item Spaces. Until now, no space was created by you. Click Create Space.
-
In the popup, enter the space name, e.g. ui5-apps. Click Create.
Now you can login to your Cloud Foundry environment directly from SAP Business Application Studio.
-
Open SAP Business Application Studio. Click in the header toolbar on View and then select Find Command.... Enter CF: Login to cloud foundry.
-
Enter the Cloud Foundry API endpoint you'd like to use. If your environment runs in the EU10 region, this is
https://api.cf.eu10.hana.ondemand.com
. If you wanna host your application in another region, please check following site to get an overview about all available regions and respective API endpoints. -
Enter the email address you have used for registering your SAP Cloud Platform account.
-
After a few seconds a small window appears in the lower right corner notifying you that the login was successful.
After logging in you're asked to specify your desired Cloud Foundry organization and space.
-
Open SAP Business Application Studio and click in the header toolbar on View and then select Find Command.... Enter CF: Set Org and Space.
-
Enter your Cloud Foundry organization name e.g. ui5-cloud-foundry.
-
After a few seconds a small window appears in the lower right corner notifying you that your organization and space have been set successfully.
Your application will be available at https://<approuter-url>/<app/id>
, and the application router will not redirect any traffic that hits the root URL. In this exercise, you will change this, so that your application will also be available at https://<approuter-url>/
.
-
Open the file
SensorManager/webapp/manifest.json
. -
Copy the value of the
sap.app/id
property. In your case, this should be keepcool.SensorManager. -
Open the file
teched2020-approuter/xs-app.json
, add a propertywelcomeFile
to define the redirect, paste the copied value of the previous step, and remove the dot from the value.
{
"authenticationMethod": "none",
"welcomeFile": "keepcoolSensorManager",
"routes": []
}
Since you created your app using one of the application templates available in SAP Business Application Studio, all files which are located under SensorManager/test/
and SensorManager/localService/
are excluded from any build, because in a productive application these files are usually not needed. In our case the sensor data is placed in a local JSON file, so the sensors.json
file needs to be included in the build.
-
Open
SensorManager/ui5.yaml
. -
Remove the
"/localService/**"
entry for thebuilder
section.
SensorManager/ui5.yaml
builder:
resources:
excludes:
- "/test/**"
Now it's time to build your application. Yeah!
-
Right-click the
mta.yaml
file in the root folder. -
Once the build has finished you'll be notified by a popup in the lower right corner.
The build step has created a file named TechEd2020_0.0.1.mtar
located under mta_archives
. This file contains your build.
-
Right-click
mta_archives/TechEd2020_0.0.1.mtar
and select Deploy MTA Archive. Deployment starts. -
Deployment should have finished after a few minutes, of which you'll be notified by a popup in the lower right corner.
-
In the deployment logs you'll find the URL of your deployed application. Copy it from the logs and paste it into a new browser tab.
-
Congratulations! You've deployed your UI5 application to SAP Cloud Platform Cloud Foundry.
Hooray! You've completed successfully Exercise 11 - Deployment to SAP Cloud Platform Cloud Foundry.
And now it's time to celebrate! By mastering this session you've reached the first level in becoming a UI5 expert.