Technical Articles
Build and Deploy Multitarget Applications in SAP Cloud Platform at Alibaba Cloud – using Cloud MTA Build Tool and Cloud Foundry CLI
You can create and deploy a Multitarget Application (MTA) in the Cloud Foundry (CF) environment as described below by following different approaches that can yield the same result:
Using the Business Application Studio (BAS).
- Both the MTA development descriptor
mta.yaml
and the deployment descriptormtad.yaml
are created automatically by BAS. - Build MTA: BAS
- Deploy MTA: BAS.
Using the Cloud MTA Build Tool.
- Development descriptor
mta.yaml
is required. You have to create it manually. - Build MTA: Cloud MTA Build Tool.
- Deploy MTA: CF CLI and MTA CF CLI Plugin.
(The Deployment service takes the real role of deployment behind, which is a build-in service in the SAP Cloud Platform.)
Manually.
- Deployment descriptor
mtad.yaml
is required, but development descriptormta.yaml
not. - Build MTA: personal choice.
- Deploy MTA: CF CLI and MTA CF CLI Plugin.
In this post, we focus on the second method using the Cloud MTA Build Tool.
Prerequisites
- Access to SAP Cloud Platform CF environment. There you need to have an account. MTA examples will be deployed in some of the account’s organization and space.
- Installed CF CLI – ensure that CF CLI is installed and working. For more information about installation of CloudFoundry CLI, please visit the official CF Documentation. For the examples, CloudFoundry CLI v7 beta is not supported. You need to have v6.4x.
- Installed MTA CF CLI Plugin – ensure that MTA CF CLI Plugin is installed and working. For more information, please visit the official GitHub Page
- Installed Cloud MTA Build Tool – the tool is used in some of the listed use cases. For more information please visit the official Cloud MTA Build Tool Documentation
- Prepared custom domain. Shared domain is not supported due to compliance in China. For more information on how to create your custom domain, please read Use custom domain in SAP Cloud Platform on Alibaba Cloud.
Build MTA
If you’ve had the deployment-ready MTA archive.mtar
file, please ignore this section and jump to the next section Deploy MTA
.
We use the Cloud MTA Build Tool to build MTA. It is a standalone command-line tool that builds a deployment-ready MTA archive .mtar
file from the artifacts of an MTA project according to the project’s MTA development descriptor (mta.yaml
file), or from the module build artifacts according to the MTA deployment descriptor (mtad.yaml
file).
If you previously used the Multitarget Application Archive Builder for building your MTA projects, see the topic: differences between the tools.
Deploy MTA
Step 1: Configuring MTA CLI plugin
Due to the deprecation of the shared domains, the URL of the SAP Cloud Platform Deployment service should be specified by each MTA developer. You can do this by exporting the environment variable MULTIAPPS_CONTROLLER_URL.
For example (Linux):
export MULTIAPPS_CONTROLLER_URL=deploy-service.cfapps.<landscape-domain>
Where, the <landscape-domain> can be found by executing CF command, which is the suffix part of api.cf
:
cf api
% cf api
api endpoint: https://api.cf.cn40.platform.sapcloud.cn
api version: 3.88.0
For the landscape in the SAP Cloud Platform at Alibaba Cloud (live), the command is:
export MULTIAPPS_CONTROLLER_URL=deploy-service.cfapps.cn40.platform.sapcloud.cn
Step 2: Specifying MTA domain in deployment descriptor
After the removal of shared domains, the Deployment service will not resolve the ${default-domain}
placeholder on Alibaba Cloud. If the placeholder is being used, you should change it to ${domain}
placeholder and additionally specify a domain
for each module. Alternatively, the routes
parameter could be used which requires the domain to be part of the route.
For example:
Before removal of shared domains on Alibaba Cloud:
ID: example-mta
modules:
- name: example1
type: javascript.nodejs
properties:
some-example-property: bar.${default-domain}
another-property: baz.${default-domain}
After removal of shared domains on Alibaba Cloud:
ID: example-mta
modules:
- name: example1
type: javascript.nodejs
parameters:
domain: <your.domain.com>
properties:
some-example-property: bar.${domain}
another-property: baz.${domain}
Usage of routes parameter after removal of shared domains on Alibaba Cloud:
ID: example-mta
modules:
- name: example1
type: javascript.nodejs
parameters:
routes:
- route: <example-host.your.domain.com>
Besides, for blue-green deployment (bg-deploy command), you should specify the idle-domain
parameter or theidle-domains
parameter.
Example withidle-domain
parameter:
ID: example-mta
modules:
- name:...
parameters:
idle-domain: "<your.idle.domain>"
Example withidle-domains
parameter:
ID: example-mta
modules:
- name:...
parameters:
idle-domains: ["<first.idle.domain>","<second.idle.domain>"]
Step 3: Deploy MTA
cf deploy <MTA_ARCHIVE>|<DIRECTORY_PATH> [-e <EXT_DESCRIPTOR_1>[,<EXT_DESCRIPTOR_2>]]
[-u <URL>] [-t <TIMEOUT>] [-v <VERSION_RULE>]
[--no-start] [--namespace]
[--delete-services] [--delete-service-keys] [--delete-service-brokers]
[][--keep-files] [--no-restart-subscribed-apps] [--do-not-fail-on-missing-permissions]
For example:
cf deploy <xxx.mtar> -f
Step 4: Examine the result
List the deployed mta:
cf mtas
cf mta <MTA-ID>
List app status and attributes:
cf app <app-name>
Reference
For more details on MTA demos and references, please visit Github repository: cf-mta-examples