Spring Cloud Services v1.3

Configuration Clients

Page last updated:

Config Server client applications can be written in any language. The interface for retrieving configuration is HTTP, and the endpoints are protected by OAuth 2.0.

To be given a base URI and client credentials for accessing a Config Server instance, a Cloud Foundry application needs to bind to the instance.

Bind an Application to a Service Instance

Click the service instance’s listing in Apps Manager. Under App Bindings, click Bind Apps.

Bind apps

Select an application and click Save.

Save binding

Alternatively, you can use the Cloud Foundry Command Line Interface tool (cf CLI). Run the command cf bind-service, specifying the application name and service instance name.

$ cf bind-service cook config-server
Binding service config-server to app cook in org myorg / space development as admin...
TIP: Use 'cf restage cook' to ensure your env variable changes take effect

Then, as the command output suggests, run the command cf restage to restage the application before proceeding. (See the next section for information about the environment variable to which the command output refers.)

$ cf restage cook
Restaging app cook in org myorg / space development as admin...

Configuration Requests and Responses

After an application is bound to the service instance, the application’s VCAP_SERVICES environment variable will contain an entry under the key p-config-server. You can view the application’s environment variables using the cf CLI:

$ cf env cook
Getting env variables for app cook in org myorg / space development as admin...

  "p-config-server": [
    "credentials": {
     "access_token_uri": "",
     "client_id": "p-config-server-c4a56a3d-9507-4c2f-9cd1-f858dbf9e11c",
     "client_secret": "9aGx9K5Vx0cM",
     "uri": ""
    "label": "p-config-server",
    "name": "config-server",
    "plan": "standard",
    "tags": [

The following is an example of a response from the Config Server to a request using the path /cook/production (where the application is cook and the profile is production).

          "cook.special":"Cake a la mode"
          "cook.special":"Pickled Cactus"

As shown in the above example, the Config Server may include multiple values for the same property in its response. In that case, the client application must decide how to interpret the response; the intent is that the first value in the list should take precedence over the others. Spring applications will do this for you automatically.

Spring Client Applications

A Spring application can use a Config Server as a property source. Properties from a Config Server will override those defined locally (e.g. via an application.yml in the classpath).

The application requests properties from the Config Server using a path such as /{application}/{profile}/[{label}] (see the Request Paths section of the The Config Server topic). It will derive values for these three parameters from the following properties:

  • {application}: or
  • {profile}: or
  • {label}: if it is defined; otherwise, the Config Server’s default label.

These values can be specified in an application.yml or file on the classpath, via a system property (as in, or (more commonly in Cloud Foundry) via an environment variable:

$ cf set-env cook SPRING_PROFILES_ACTIVE production

Given the above example response for the request path /cook/production, a Spring application would give the two Config Server property sources precedence over other property sources. This means that properties from would have precedence over properties from, which would have precedence over properties from the application’s other property sources (such as classpath:application.yml).

For a specific example of using a Spring application as a Config Server client, see the Writing Client Applications topic.

Create a pull request or raise an issue on the source for this page in GitHub