Configuring Environment Variables for Virtual Services
Rather than hard-coding recurring configuration values in a virtual service, transaction, or processing action, you can define environment variables for virtual services to use at runtime, such as a different server and port for testing and staging. Use the Configurations tab to create custom configurations to store your attribute-value pairs. To use a configuration value, refer to it in ${config.name}
format. For example, to reference a custom port, use ${config.port}
.
Create a Virtual Services Configuration
Before deploying a virtual service, create and select the desired configuration.
- Go to the Service Virtualization tab and open the Configurations tab.
- For each configuration, click Create New Configuration.
- Enter a Name for the configuration, for example
staging
,development
,testing
. - (Optional) Enter a Description that informs team members of the purpose of this configuration.
- For each property, click Add Property and enter a Name and its Value.
- Click Save.
Now you can use the values and enable this configuration for a virtual service.
Use the Configuration Values
- Go to the Service Virtualization tab and open the virtual service.
- For each virtual service, identify the respective hard-coded values.
- Replace the hard-coded values with custom properties in
${config.name}
format.Click the Copy button next to the property name to copy the correct syntax into the clipboard.
Enable or Change a Virtual Services Configuration
You cannot change the active configuration while the virtual service is running.
- Go to the Service Virtualization tab and open the virtual service.
- If the virtual service is running, click Stop.
- (Optional) Edit the configuration values on the Configurations tab if needed.
- Open the virtual service definition and select the desired configuration.
- Click Run Virtual Service to restart the virtual service with the new profile.