如何将不同的 Watson Discovery 绑定到每个 CF 应用程序

How Can I bind different Watson Discovery to each CF application

我正在使用一个资源组、一个 CF 组织、一个 Space。

创建 CF 应用程序

我将不同的 Watson Discovery 绑定到每个 CF 应用程序。

当我收到一条错误消息

 "Error response from the server. Status code: 400; description: 400 Code: BXNIM0150E, Message: The service name part of the provided CRNs must be unique, Details: Service name 'discovery' must be unique for all provided CRNs."

具体来说,第一个绑定 (A_0001_APP) 似乎工作正常,但第二个绑定 (D_0001_APP) 没有按预期工作。

这是正确的方法吗?

任何帮助将不胜感激。

这是一个简化的日志。

####################################################################################
# Bind to A_0001_APP -> That is absolutely fine.
####################################################################################
$ ibmcloud target
API endpoint:      https://api.au-syd.bluemix.net
Region:            au-syd
User:              *************************
Account:           *************************
Resource group:    d_resource01
CF API endpoint:   https://api.au-syd.bluemix.net (API version: 2.106.0)
Org:               d_org01
Space:             dev


$ ibmcloud cf push A_0001_APP
.....


$ ibmcloud resource service-instance-create A_0001_DISCOVERY discovery advanced jp-tok
Creating service instance A_0001_DISCOVERY in resource group d_resource01 of account *************************
OK
Service instance A_0001_DISCOVERY was created.
Name               Location   State      Type               Tags
A_0001_DISCOVERY   jp-tok     inactive   service_instance


$ ibmcloud resource service-key-create A_0001_DISCOVERY_CREDENTIAL Manager --instance-name A_0001_DISCOVERY
Creating service key of service instance A_0001_DISCOVERY under account *************************.
OK
Service key crn:v1:bluemix:public:discovery:jp-tok:a/*************************:resource-key:************************* was created.
Name:          A_0001_DISCOVERY_CREDENTIAL
ID:            crn:v1:bluemix:public:discovery:jp-tok:a/*************************:*************************:resource-key:*************************
Created At:    Mon Nov 19 07:57:03 UTC 2018
State:         active
Credentials:   .......

$ ibmcloud resource service-alias-create A_0001_DISCOVERY_ALIAS --instance-name A_0001_DISCOVERY
Creating alias A_0001_DISCOVERY_ALIAS of service instance A_0001_DISCOVERY from resource group d_resource01 into space dev...
OK
Service alias A_0001_DISCOVERY_ALIAS was successfully created.

ID:                 crn:v1:bluemix:public:discovery:au-syd:a//*************************::/*************************::resource-alias:/*************************:
Name:               A_0001_DISCOVERY_ALIAS
State               active
Service Instance:   A_0001_DISCOVERY
Space:              dev
Tags:
Parameters:

$ ibmcloud resource service-binding-create A_0001_DISCOVERY_ALIAS A_0001_APP Manager --service-id my_service
Binding service alias A_0001_DISCOVERY_ALIAS to app A_0001_APP in space dev...
OK
Service binding crn:v1:bluemix:public:discovery:au-syd:a/:*************************:resource-binding::************************* was created.


####################################################################################
# Bind to D_0001_APP -> I can't create service-binding.
####################################################################################
$ ibmcloud target
API endpoint:      https://api.au-syd.bluemix.net
Region:            au-syd
User:              *************************
Account:           *************************
Resource group:    d_resource01
CF API endpoint:   https://api.au-syd.bluemix.net (API version: 2.106.0)
Org:               d_org01
Space:             dev

$ ibmcloud cf push D_0001_APP
.....

$ ibmcloud resource service-instance-create D_0001_DISCOVERY discovery advanced jp-tok
Creating service instance D_0001_DISCOVERY in resource group d_resource01 of account *************************
OK
Service instance D_0001_DISCOVERY was created.
Name               Location   State      Type               Tags
D_0001_DISCOVERY   jp-tok     inactive   service_instance

$ ibmcloud resource service-key-create D_0001_DISCOVERY_CREDENTIAL Manager --instance-name D_0001_DISCOVERY
Creating service key of service instance D_0001_DISCOVERY under account *************************.
OK
Service key crn:v1:bluemix:public:discovery:jp-tok:a/*************************:resource-key:************************* was created.
Name:          D_0001_DISCOVERY_CREDENTIAL
ID:            crn:v1:bluemix:public:discovery:jp-tok:a/*************************:*************************:resource-key:*************************
Created At:    Tue Nov 20 10:12:56 UTC 2018
State:         active
Credentials:    .......

$ ibmcloud resource service-alias-create D_0001_DISCOVERY_ALIAS --instance-name D_0001_DISCOVERY
Creating alias D_0001_DISCOVERY_ALIAS of service instance D_0001_DISCOVERY from resource group d_resource01 into space dev...
OK
Service alias D_0001_DISCOVERY_ALIAS was successfully created.
ID:                 crn:v1:bluemix:public:discovery:au-syd:a//*************************::/*************************::resource-alias:/*************************:
Name:               D_0001_DISCOVERY_ALIAS
State               active
Service Instance:   D_0001_DISCOVERY
Space:              dev
Tags:
Parameters:

$ ibmcloud resource service-binding-create D_0001_DISCOVERY_ALIAS D_0001_APP Manager --service-id my_service
Binding service alias D_0001_DISCOVERY_ALIAS to app D_0001_APP in space dev...
FAILED
Error response from the server. Status code: 400; description: 400 Code: BXNIM0150E, Message: The service name part of the provided CRNs must be unique, Details: Service name 'discovery' must be unique for all provided CRNs.
script returned exit code 1

如错误中所述,CRN(云资源名称)的服务名称部分必须是唯一的。

CRN 的基本规范格式是:

crn:version:cname:ctype:service-name:location:scope:service-instance:resource-type:resource

服务名称段唯一标识云提供的功能(服务、组件、产品)。该功能可以是用户提供的服务,例如 IBM Cloud 目录中列出的服务,也可以是对 IBM Cloud 功能至关重要的内部架构组件。

service-name表示资源所属的服务,IBM Cloud强制服务名称全局唯一。服务名称必须是字母数字、小写字母、无空格或除“-”以外的特殊字符。

是的。我能够使用唯一的别名重现该问题,对我有用的是不同的服务 ID

ibmcloud resource service-binding-create D_0001_DISCOVERY_ALIAS D_0001_APP Manager --service-id myserviceID