You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/cap-service-deploy/cap-service-deploy.md
+35-72Lines changed: 35 additions & 72 deletions
Original file line number
Diff line number
Diff line change
@@ -10,20 +10,22 @@ time: 30
10
10
---
11
11
12
12
## 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).
14
14
- 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).
15
15
- 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).
16
18
- 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
17
19
18
20
## Details
19
-
### You will learn
21
+
### You will learn
20
22
- 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.
21
23
22
24
---
23
25
24
-
[ACCORDION-BEGIN [Step 1: ](Enhance project configuration for SAP HANA)]
26
+
[ACCORDION-BEGIN [Step 1: ](Enhance project configuration for production)]
25
27
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.
27
29
28
30
> ### 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.
29
31
@@ -32,12 +34,20 @@ It's now time to switch to SAP HANA as a database. To continue with this tutoria
32
34
2. To prepare the project, execute in the root level of your project in VS Code:
33
35
34
36
```Shell/Bash
35
-
cds add hana
37
+
cds add hana,mta,xsuaa,approuter --for production
36
38
```
37
39
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.
39
41
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.
41
51
42
52
3. (Optional) To enable SAP Fiori preview add the following configuration in the `package.json` of your `my-bookshop` project in VS Code:
43
53
@@ -47,12 +57,12 @@ It's now time to switch to SAP HANA as a database. To continue with this tutoria
47
57
"fiori_preview": true
48
58
},
49
59
}
50
-
```
51
60
61
+
```
52
62
> `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.
53
63
54
64
> Don't edit the `gen/db/package.json` file.
55
-
65
+
56
66
[DONE]
57
67
58
68
[ACCORDION-END]
@@ -90,88 +100,41 @@ The Cloud Foundry API endpoint is required so that you can log on to your SAP BT
90
100
[DONE]
91
101
[ACCORDION-END]
92
102
93
-
[ACCORDION-BEGIN [Step 3: ](Deploy using cf push)]
103
+
[ACCORDION-BEGIN [Step 3: ](Deploy using cf deploy)]
94
104
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)
96
106
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.
100
108
109
+
1. In VS Code, in the root of your project, execute the following command to build the archive.
101
110
```Shell/Bash
102
-
cf create-service hana hdi-shared my-bookshop-db
111
+
mbt build -t gen --mtar mta.tar
103
112
```
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`.
104
114
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`.
113
116
```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
117
118
```
119
+
During deployment all needed service instances are created and the applications as well as database artifacts are deployed.
118
120
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.
123
122
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`:
Application "my-bookshop" started and available at "[org]-[space]-my-bookshop.cfapps.[region].hana.ondemand.com"
130
127
```
128
+
This is the URL of the AppRouter, which enforces the authentication flow.
131
129
132
130
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**.
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:
> 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:
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**.
> You've deployed your CAP application as multitarget application including deployment to SAP HANA Cloud, using the standalone AppRouter, and using authentication (XSUAA). Congratulations!
0 commit comments