Ошибка при привязке экземпляра службы в SAP CAP с использованием внешней службы
В SAP CAP я следую этой ссылке примера блога для создания проекта CAP, использующего внешнюю службу. Однако во время развертывания в Clound Foundry я столкнулся с ошибкой ниже:
При развертывании произошла ошибка:
Updating application "external-service-srv"...
Unbinding service instance "external-service-uaa" from application "external-service-srv"...
Binding service instance "external-service-uaa" to application "external-service-srv"...
Binding service instance "external-service-destination" to application "external-service-srv"...
Error while binding service instance "external-service-destination" to application "external-service-srv": Could not bind service "external-service-destination" to application "external-service-srv": 404 Not Found: Service instance external-service-destination not found.
Proceeding with automatic retry... (3 of 3 attempts left)
Ниже фрагмент кода мои конфигурации:
mta.yaml
_schema-version: '3.1'
ID: external-service
version: 1.0.0
description: A simple CAP project.
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm ci
- npx -p @sap/cds-dk cds build --production
modules:
- name: external-service-srv
type: nodejs
path: gen/srv
parameters:
buildpack: nodejs_buildpack
build-parameters:
builder: npm-ci
provides:
- name: srv-api
properties:
srv-url: '${default-url}'
requires:
- name: external-service-destination
- name: external-service-uaa
resources:
- name: external-service-destination
type: org.cloudfoundry.existing-service
parameters:
service: destination
service-name: external-service-destination
- name: external-service-uaa
type: org.cloudfoundry.managed-service
parameters:
path: ./xs-security.json
service: xsuaa
service-plan: application
xs-security.json
{
"xsappname": "external-service",
"tenant-mode": "dedicated",
"scopes": [],
"attributes": [],
"role-templates": []
}
пакет.json
{
"name": "external-service",
"version": "1.0.0",
"description": "A simple CAP project.",
"repository": "<Add your repository here>",
"license": "UNLICENSED",
"private": true,
"dependencies": {
"@sap/cds": "^5",
"express": "^4"
},
"devDependencies": {
"sqlite3": "^5.0.2"
},
"scripts": {
"start": "cds run"
},
"eslintConfig": {
"extends": "eslint:recommended",
"env": {
"es2020": true,
"node": true,
"jest": true,
"mocha": true
},
"globals": {
"SELECT": true,
"INSERT": true,
"UPDATE": true,
"DELETE": true,
"CREATE": true,
"DROP": true,
"CDL": true,
"CQL": true,
"CXL": true,
"cds": true
},
"rules": {
"no-console": "off",
"require-atomic-updates": "off"
}
},
"cds": {
"requires": {
"NorthWind": {
"kind": "odata-v2",
"model": "srv/external/NorthWind",
"credentials": {
"destination": "NorthWind"
}
}
}
}
}
Ошибка гласит, что экземпляр external-service-destination в mta.yaml не найден.
Обновление: мне удалось исправить проблему
Для тех, кто столкнулся с такой проблемой, обратите внимание на обновленный конфиг mta.yaml . Я следую этому руководству , и оно решило мою проблему во время развертывания BTP в Cloud Foundry.
mta.yaml
_schema-version: '3.1'
ID: external-service
version: 1.0.0
description: A simple CAP project.
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm ci
- npx -p @sap/cds-dk cds build --production
modules:
- name: external-service-srv
type: nodejs
path: gen/srv
parameters:
buildpack: nodejs_buildpack
build-parameters:
builder: npm-ci
provides:
- name: srv-api
properties:
srv-url: '${default-url}'
requires:
- name: external-service-dest
- name: external-service-uaa
resources:
- name: external-service-dest
type: org.cloudfoundry.managed-service
parameters:
service: destination
service-name: external-service-dest
service-plan: lite
- name: external-service-uaa
type: org.cloudfoundry.managed-service
parameters:
path: ./xs-security.json
service: xsuaa
service-plan: application
service-name: external-service-uaa