-
Notifications
You must be signed in to change notification settings - Fork 8
Binding applications to a service instance
An instance of a service must be created in order to bind your application to that service. See Creating a new Service Instance for instructions.
- On the TAP console, navigate to Applications from the main menu.
- Search for the application you wish to bind and click the See Details>> link on the far right of the application row.
- On the application details page, select the Bindings tab to both see the services already bound to the application, and a list of the available services to choose for new bindings.
- Click the Bind button for the service you want to bind to the application.
- The application must be restaged after binding to a service. Select the Restage>> button to restage the application.
##Accessing a Service from an Application Once your application is bound to the service, and your application is pushed (or restarted), credentials for the service instance will be delivered to the application runtime in an environment variable named VCAP_SERVICES. VCAP_SERVICES returns a JSON document containing objects that allow your application to access the service. You can access the environment variables of an application by invoking:
cf env APP-NAME
For detailed information, read [the Cloud Foundry docs] (http://docs.cloudfoundry.org/devguide/deploy-apps/environment-variable.html#VCAP-SERVICES).
Here are some implementation examples:
- [Java] (https://github.com/ProKarma-Inc/TAP-readmissions-reduction/blob/41cd8ed43b14fe46293ca36f99e9dd1089a3f40f/src/UI/patient-risk-api/config/mongodb.js
)
- [Golang] (https://github.com/trustedanalytics/application-broker/blob/3593eca396848e9fe67709df3fe8508d6d69fcd0/dao/mongo.go#L17-L51#bind)
- [Python] (https://github.com/trustedanalytics/data-catalog/blob/master/data_catalog/configuration.py#L30-L108#bind)
In the case of Spring projects, you should read the [Cloud Foundry documentation] (https://docs.cloudfoundry.org/buildpacks/java/spring-service-bindings.html#bind) on this topic.