Re: CF Environment Variable Interpolation


Scott Frederick <scottyfred@...>
 

Olga,

Diego migration should not have affected this Spring Boot behavior. Here
are a few things to look at to diagnose the problem.

Use the cf CLI to view the environment for your application - e.g. “cf env
my-app”. This should show a VCAP_SERVICES environment variable containing
the credentials and connection info for all services bound to the app. If
the “dashboardService” isn’t in VCAP_SERVICES, then the app likely became
unbound during the migration. Re-binding should correct the issue.

If the “dashboardService” is in VCAP_SERVICES, then you can look at how
Spring Boot is processing the environment variable. Add Actuators to your
app
<http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#production-ready-enabling>
if it isn’t there already, then access the “/env” endpoint on the app with
a browser or curl. There should be a property source named “vcap” in the
JSON returned from “/env” containing all the properties you are looking
for.

If the “dashboardService” is in VCAP_SERVICES but isn’t showing property in
the Actuator “/env” endpoint, then reply with what you do see.

Scott

On Tue, Feb 7, 2017 at 8:25 AM, Chip Childers <cchilders(a)cloudfoundry.org>
wrote:

Have you confirmed that your application is still bound to the relevant
service instance?

On Mon, Feb 6, 2017 at 10:43 AM Olga Reva <reva.olga(a)gmail.com> wrote:

Since migration to Diego, our Spring Boot Applications cannot access
properties defined in application.properties files like the following:

gateway.services.dashboard = ${vcap.services.
dashboardService.credentials.url:http://localhost:8081}
gateway.credentials.dashboard.username=${vcap.services.
dashboardService.credentials.username:username1}
gateway.credentials.dashboard.password=${vcap.services.
dashboardService.credentials.password:pwd1}

I.e. app try to connect to http://localhost:8081 instead of using of
predefined variables vcap.services.dashboardService.credentials.url...

How to change configs to access variables using vcap.services...
?
Can anybody help me?
--
Chip Childers
CTO, Cloud Foundry Foundation
1.267.250.0815 <(267)%20250-0815>

Join {cf-dev@lists.cloudfoundry.org to automatically receive all group messages.