Reading Time: 10 minutes

In MuleSoft, application properties for CloudHub 2.0 are configuration settings that allow you to externalize and manage application-specific parameters separately from your application code. These properties are commonly used to define application and environment specific configurations, such as Salesforce connection details, connection credentials, API endpoints, ports and other configurable parameters.

Benefits of application properties in Mule apps

Application properties in Mule applications are typically defined in one or more property files, usually in YAML or properties format. These files are stored outside of the application code and are loaded by the Mule runtime environment at runtime. This externalization of configuration settings offers several benefits.

Environment-specific configurations

Application properties allow you to define environment-specific configurations for different deployment environments, such as development, testing, and production. This flexibility allows you to reuse the same application code across multiple environments with different configurations.

Securely store information

Storing sensitive information, such as credentials, in property files allows you to manage access control and encryption separately from the application code. This helps improve security by reducing the risk of exposing sensitive information in the source code.

Concern separation  

By externalizing configuration settings, you can separate application logic from configuration details. This makes it easier to manage and update configurations without modifying the application code.

Ease of maintenance

By centralizing configuration settings in property files, you can easily update and manage configurations without redeploying the application. This simplifies maintenance and reduces downtime associated with configuration changes.

Scalability and reusability

Application properties promote scalability and reusability by allowing you to parameterize your application configurations. This makes it easier to scale your application across different environments and reuse configurations across multiple applications.

Specifying Property Values

You can specify the values of each property in either Anypoint Runtime Manager or a properties file. If you set properties both in the properties file in your application and in Runtime Manager, the values set in Runtime Manager always override the values in the properties file when your application deploys.

For example, you can configure a Salesforce connector in which the username is set to ${sf.username} and the password is set to ${sf.password}. In Runtime Manager, you can set these two properties as application properties.

You can add properties to an app by including a file in the property placeholder YAML file deployable application archive file. See Configuring Properties.

Properties file is a text file that contains the key/value pair representing the property value and its property placeholder name. The file can be either a Java property format file or a YAML file format.

Java style properties file format:

sf.username=username
sf.password=password
sf.token=xxxxxtokenxxxxx
sf.url=https://<my-domain>.my.salesforce.com/services/Soap/u/56.0

YAML style properties file format:

sf:
  username : "username"
  password : "password"
  token : "xxxxxtokenxxxxx"
  url : "https://<my-domain>.my.salesforce.com/services/Soap/u/56.0"

For the rest of this article, we will focus on how you can protect your application property values using Anypoint Runtime Manager. 

Note: You can encrypt configuration properties by encrypting the entire properties file using the Secure Properties Tool. The Secure Properties Tool in MuleSoft is a command-line utility designed to facilitate the encryption and decryption of sensitive property values in Mule application configuration files. For more information please refer to Secure Configuration Properties.

Define Properties for Mule applications

First, create a Property file in your application. The Mule properties file in Java Properties or YAML is created in your mule project’s src/main/resources folder. The properties values can be used to configure different properties of your mule application. 

Once you have configured your properties file and added it to your project, you can reference its attributes by using a syntax like this:

 ${propertyContainer.propertyName}

Now, let’s see how to configure a Salesforce connector in Anypoint Studio using the values defined in the properties file (rather than the static values for each field).

Salesforce Configuration page where you can specify username, password, security token, and authorization URL

Protect Property Values in Runtime Manager

After deploying your application to CloudHub 2.0, you can update the properties of the deployed application using the Runtime Manager.

  • Log in to your Anypoint Platform Organization, then go to Runtime Manager
  • Select the application you want to update the properties for, then click Manage application
  • If you’re deploying the application, update the properties tab during deployment of the application
View of Anypoint Runtime Manager that highlights the Salesforce application we created in Anypoint Studio. Highlights the application and “manage application” button.
  • Click on the Properties tab, then select the Table view
  • Alternatively, you can click Text view and enter the key-value pair in the text field in this format: New Key=New Value
Configuration Properties for the application in Anypoint Runtime Manager
  • Add the property and its value in the Table view
  • If you want to add multiple property values at one time, select the Text view and add key-value pairs
  • Switch to the Table view to protect individual values
Table view of the properties configuration of Salesforce System API that reveals sensitive information such as token and password
  • Click on Protect button on the right side of each property in the Table view 
  • A dialog will pop up to confirm, which will prompt you to click on Protect value
Protect value confirmation pop up box
  • Protect each value that you don’t want to be displayed on the Properties tab to any Anypoint Platform user
  • The protected value will not be displayed on the properties tab
  • Click on Apply Changes to make the changes effective

The properties table now with the sensitive data such as token and password hidden.
  • Now any user with even the highest privilege will not be able to view the properties that were protected
  • You cannot retrieve the properties once they are protected. If you have to update, then you have to choose Replace Protected value with new protected value
 shows the options to “Replace protected value” and “Delete property”

Updated, secured runtime properties

Application Properties in CloudHub 2.0 provides an easy way to update and secure your application’s runtime properties. With this feature, you can now streamline your test, dev, and production environments.

Your app developers can deploy the application with the test credentials and test instances. Runtime Administrators can update the runtime properties in the production environment. Want to learn more? Read our extensive documentation on managing properties for applications on CloudHub.