Skip to content

Commit f24a7e5

Browse files
Switched deployment to MTA (#18432)
* Automatic commit: Move 'cap-service-deploy' from QA to Production * Automatic commit: Move 'cap-service-deploy' from QA to Production
1 parent 7f0e72a commit f24a7e5

File tree

1 file changed

+35
-72
lines changed

1 file changed

+35
-72
lines changed

tutorials/cap-service-deploy/cap-service-deploy.md

Lines changed: 35 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@ time: 30
1010
---
1111

1212
## Prerequisites
13-
- You have finished the tutorial [Create a CAP Business Service with Node.js using Visual Studio Code](cp-apm-nodejs-create-service).
13+
- You have finished the tutorial [Create a CAP Business Service with Node.js using Visual Studio Code](cp-apm-nodejs-create-service).
1414
- If you don't have a Cloud Foundry Trial subaccount and dev space on [SAP BTP Cockpit](https://cockpit.hanatrial.ondemand.com/cockpit/) yet, create your [Cloud Foundry Trial Account](hcp-create-trial-account) with **US East (VA) as region** and, if necessary [Manage Entitlements](cp-trial-entitlements).
1515
- You have downloaded and installed the [cf command line client](https://github.com/cloudfoundry/cli#downloads) for Cloud Foundry as described in the tutorial [Install the Cloud Foundry Command Line Interface (CLI)](cp-cf-download-cli).
16+
- You have downloaded and installed the [MBT Built Tool](https://sap.github.io/cloud-mta-build-tool/download/)
17+
- You have downloaded and installed the [MultiApps CF CLI plugin](https://github.com/cloudfoundry/multiapps-cli-plugin/blob/master/README.md).
1618
- You have to [Use an existing SAP HANA Cloud service instance](https://developers.sap.com/tutorials/btp-app-hana-cloud-setup.html#42a0e8d7-8593-48f1-9a0e-67ef7ee4df18) or [set up a new SAP HANA Cloud service instance](https://developers.sap.com/tutorials/btp-app-hana-cloud-setup.html#3b20e31c-e9eb-44f7-98ed-ceabfd9e586e) to deploy your CAP application
1719

1820
## Details
19-
### You will learn
21+
### You will learn
2022
- How to deploy your CAP business service on SAP Business Technology Platform (SAP BTP) and binding appropriate service instances. See the [Developer Guide for Cloud Foundry](https://docs.cloudfoundry.org/devguide/) for more details.
2123

2224
---
2325

24-
[ACCORDION-BEGIN [Step 1: ](Enhance project configuration for SAP HANA)]
26+
[ACCORDION-BEGIN [Step 1: ](Enhance project configuration for production)]
2527

26-
It's now time to switch to SAP HANA as a database. To continue with this tutorial you need to [Use an existing SAP HANA Cloud service instance](https://developers.sap.com/tutorials/btp-app-hana-cloud-setup.html#42a0e8d7-8593-48f1-9a0e-67ef7ee4df18) or [set up a new SAP HANA Cloud service instance](https://developers.sap.com/tutorials/btp-app-hana-cloud-setup.html#3b20e31c-e9eb-44f7-98ed-ceabfd9e586e) to deploy your CAP application.
28+
It's now time to switch to SAP HANA as a database and prepare your project for an MTA deployment to SAP BTP Cloud Foundry. To continue with this tutorial you need to [Use an existing SAP HANA Cloud service instance](https://developers.sap.com/tutorials/btp-app-hana-cloud-setup.html#42a0e8d7-8593-48f1-9a0e-67ef7ee4df18) or [set up a new SAP HANA Cloud service instance](https://developers.sap.com/tutorials/btp-app-hana-cloud-setup.html#3b20e31c-e9eb-44f7-98ed-ceabfd9e586e) to deploy your CAP application.
2729

2830
> ### Your SAP HANA Cloud service instance will be automatically stopped overnight, according to the server region time zone. That means you need to restart your instance every day, before you start working with your trial.
2931
@@ -32,12 +34,20 @@ It's now time to switch to SAP HANA as a database. To continue with this tutoria
3234
2. To prepare the project, execute in the root level of your project in VS Code:
3335

3436
```Shell/Bash
35-
cds add hana
37+
cds add hana,mta,xsuaa,approuter --for production
3638
```
3739
38-
> This configures deployment for SAP HANA to use the `hdbtable` and `hdbview` formats. The default format of `hdbcds` is not available on SAP HANA Cloud.
40+
> `--for production` adds all configuration added by this command in the `package.json` file into a `cds.requires.[production]` block.
3941
40-
> The `hdb` driver for SAP HANA is added as a dependency. A data source of type `sql` is added in the `cds.requires.db` block. See section [Node.js configuration](https://cap.cloud.sap/docs/node.js/cds-env#profiles) in the CAP documentation for more details.
42+
> `hana` configures deployment for SAP HANA to use the `hdbtable` and `hdbview` formats. The default format of `hdbcds` is not available on SAP HANA Cloud. In addition, the `hdb` driver for SAP HANA is added as a dependency. A data source of type `hana-cloud` is added in the `cds.requires.[production].db` block. See section [Node.js configuration](https://cap.cloud.sap/docs/node.js/cds-env#profiles) in the CAP documentation for more details.
43+
44+
> `mta` adds the `mta.yaml` file. This file reflects your project configuration.
45+
46+
> `xsuaa` creates an `xs-security.json` and also the needed configuration in the `mta.yaml` file. An authentication of kind `xsuaa` is added in the `cds.requires.[production].auth` block.
47+
48+
> `approuter` adds the configuration and needed files for a standalone AppRouter so that the authentication flow works after deployment.
49+
50+
Learn more about those steps in the [Deploy to Cloud Foundry](https://cap.cloud.sap/docs/guides/deployment/to-cf#prepare-for-production) guide in the CAP documentation.
4151
4252
3. (Optional) To enable SAP Fiori preview add the following configuration in the `package.json` of your `my-bookshop` project in VS Code:
4353
@@ -47,12 +57,12 @@ It's now time to switch to SAP HANA as a database. To continue with this tutoria
4757
"fiori_preview": true
4858
},
4959
}
50-
```
5160
61+
```
5262
> `fiori_preview:true` enables SAP Fiori preview also in `production` mode as you saw it in your local application in the previous tutorial in step 4 when using `cds watch`. This feature is meant to help you during development and should not be used in productive applications.
5363
5464
> Don't edit the `gen/db/package.json` file.
55-
65+
5666
[DONE]
5767
5868
[ACCORDION-END]
@@ -90,88 +100,41 @@ The Cloud Foundry API endpoint is required so that you can log on to your SAP BT
90100
[DONE]
91101
[ACCORDION-END]
92102
93-
[ACCORDION-BEGIN [Step 3: ](Deploy using cf push)]
103+
[ACCORDION-BEGIN [Step 3: ](Deploy using cf deploy)]
94104
95-
SAP BTP, Cloud Foundry environment has a built-in [cf push](https://docs.cloudfoundry.org/devguide/push.html) command to deploy applications. It needs the application files plus an optional `manifest.yml` file to push the application code and to bind the relevant services to the application.
105+
SAP provides an application format that respects the single modules and their technologies and keeps those modules in the same lifecycle: [Multitarget Application](https://help.sap.com/docs/BTP/65de2977205c403bbc107264b8eccf4b/d04fc0e2ad894545aebfd7126384307c.html?version=Cloud)
96106
97-
[OPTION BEGIN [Windows]]
98-
99-
1. As `cf push` can only bind but not create services, you need to create the SAP HANA service manually (along with an HDI container and a database schema). In the command line add:
107+
The MBT Build tool uses the `mta.yaml` file that has been created using `cds add mta` before, to build the deployable archive. The MultiApps CF CLI plugin adds the `deploy` command and orchestrates the deployment steps.
100108
109+
1. In VS Code, in the root of your project, execute the following command to build the archive.
101110
```Shell/Bash
102-
cf create-service hana hdi-shared my-bookshop-db
111+
mbt build -t gen --mtar mta.tar
103112
```
113+
The `-t` option defines the target folder of the build result as the `gen` folder of your project. As part of this build implicitly `cds build --production` is executed. This implicit build uses then all the configuration you've added in the step 1.2 when using `--for production`.
104114
105-
> This process takes some minutes.
106-
107-
> Check the status of your service using `cf service my-bookshop-db`.
108-
109-
> If service creation fails, see the [Troubleshooting guide](https://cap.cloud.sap/docs/advanced/troubleshooting#hana) in the CAP documentation for more details.
110-
111-
2. Now, build and deploy both the database part and the actual application and add:
112-
115+
2. Deploy the archive using `cf deploy`.
113116
```Shell/Bash
114-
cds build --production
115-
cf push -f gen/db
116-
cf push -f gen/srv --random-route
117+
cf deploy gen/mta.tar
117118
```
119+
During deployment all needed service instances are created and the applications as well as database artifacts are deployed.
118120
119-
> This process takes some minutes.
120-
121-
> The first part of the command creates the SAP HANA table and view definitions along with `manifest.yaml` files in both in `gen/db` and `gen/srv` folders. Look at `gen/db/manifest.yaml` and see that it binds to the `my-bookshop-db` service that you've created in the previous step.
122-
121+
> This process takes some minutes. In this one step the archive is uploaded to Cloud Foundry, service instances are created, the applications are staged, and then deployed to their target runtimes.
123122
124-
3. In the deploy log, find the application URL in the `routes` line at the end:
123+
3. In the deploy log, find the application URL of `my-bookshop`:
125124
126125
```Shell/Bash
127-
name: my-bookshop-srv
128-
requested state: started
129-
routes: my-bookshop-srv-....cfapps.....hana.ondemand.com
126+
Application "my-bookshop" started and available at "[org]-[space]-my-bookshop.cfapps.[region].hana.ondemand.com"
130127
```
128+
This is the URL of the AppRouter, which enforces the authentication flow.
131129
132130
4. Open this URL in the browser and try out the provided links, for example, `.../catalog/Books`. Application data is fetched from SAP HANA. If enabled in step 1.3 you can also try the **Fiori preview**.
133131
134132
!![application preview](application_cloud_fiori.png)
135133
136-
[OPTION END]
137-
138-
[OPTION BEGIN [MacOS and Linux]]
139-
140-
1. As `cf push` can only bind but not create services, you need to create the SAP HANA service manually (along with an HDI container and a database schema). In the command line add:
141-
142-
```Shell/Bash
143-
cf create-service hana hdi-shared my-bookshop-db
144-
```
145-
146-
> This process takes some minutes.
147-
148-
> Check the status of your service using `cf service my-bookshop-db`.
149-
150-
> If service creation fails, see the [Troubleshooting guide](https://cap.cloud.sap/docs/advanced/troubleshooting#hana) in the CAP documentation for more details.
151-
152-
2. Now, build and deploy both the database part and the actual application and add:
153-
154-
```Shell/Bash
155-
cds build --production && cf push -f gen/db && cf push -f gen/srv --random-route
156-
```
157-
158-
> This process takes some minutes.
159-
160-
> The first part of the command creates the SAP HANA table and view definitions along with `manifest.yaml` files in both in `gen/db` and `gen/srv` folders. Look at `gen/db/manifest.yaml` and see that it binds to the `my-bookshop-db` service that you've created in the previous step.
161-
162-
3. In the deploy log, find the application URL in the `routes` line at the end:
163-
164-
```Shell/Bash
165-
name: my-bookshop-srv
166-
requested state: started
167-
routes: my-bookshop-srv-....cfapps.....hana.ondemand.com
168-
```
169-
170-
4. Open this URL in your browser and try out the provided links, for example, `.../catalog/Books`. Application data is fetched from SAP HANA. If enabled in step 1.3 you can also try the **Fiori preview**.
171-
172-
!![application preview](application_cloud_fiori.png)
134+
> What you achieved
135+
>
136+
> You've deployed your CAP application as multitarget application including deployment to SAP HANA Cloud, using the standalone AppRouter, and using authentication (XSUAA). Congratulations!
173137
174-
[OPTION END]
175138
176139
[VALIDATE_1]
177140

0 commit comments

Comments
 (0)