Configuration of Bluemix Apps via User Provided Services

When Bluemix services are created and bound to applications, they usually provision all artifacts needed to use the services. As result of this provisioning they return information to Bluemix that is needed to the services, for example user credentials. This information is stored in the Bluemix environment variable VCAP_SERVICES and can be accessed from applications.

Sometimes however you need additional configuration for your applications which shouldn’t be hardcoded. This can be configuration which is not associated with a particular Bluemix service or additional configuration for Bluemix services. For example the single sign on service requires a redirect URL and a client id and secret.

There are several approaches to configure Bluemix apps, for example user-defined variables which are additional environment variables. For Bluemix.info we use an user provided service. User provided services show up in the Bluemix dashboard as other services and can include configuration parameters. They can be created via the cf command line tool and then easily be accessed.

In order to access this configuration we use classes like ConfigUtilities. This class also abstracts whether the application is run on Bluemix or locally. When running locally we store the same information in local environment variables.