Managing Environment Variables of an Application
Environment variables of an application are parameters set in the system or user applications. You can obtain the values of environment variables by calling APIs. During deployment, parameters are specified through environment variables instead of in the code, which makes the deployment flexible. Environment variables added to an application are global environment variables and take effect for all application components.
To add environment variables for a specific component:
- For container-deployed components, see Adding an Environment Variable of a Component.
- For VM-deployed components, see Adding an Environment Variable of a Component.
For details about environment variables of an environment, see Managing Environment Variables of an Environment.
Before using environment variables of an application, add environment variables for the application. You can add environment variables of an application by Manually Adding an Environment Variable or Importing Environment Variables, or Editing an Environment Variable and Deleting an Environment Variable based on service requirements.
Manually Adding an Environment Variable
- Log in to ServiceStage.
- Choose Application Management.
- Click the target application. The Overview page is displayed.
- In the left navigation pane, click Environment Variables.
- Select a created environment from the drop-down list.
- Set the policy for the environment variables to take effect.
- First Time Effective: The environment variables take effect only when the component is created for the first time. Subsequent modifications to the environment variables will not be synchronized to the existing components of the application.
- Continuously Effective: The modification of environment variables will be synchronized to the existing components of the application through component upgrade.
- First Time Effective: The environment variables take effect only when the component is created for the first time. Subsequent modifications to the environment variables will not be synchronized to the existing components of the application.
- Click Add Environment Variable and set Name and Variable/Variable Reference.
Exercise caution when inputting sensitive information in configuring environment variables, or encrypt sensitive information to avoid information leakage.
- Name: application environment variable name, which must be unique in the same application environment. Enter 1 to 64 characters. Start with a letter, underscore (_), or hyphen (-). Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- Variable/Variable Reference: application environment variable value.
For example, if you set Name to User and Variable/Variable Reference to admin, when the program code reads the User environment variable, admin is obtained. Or, you can start a subprocess or read a file as user admin. The actual execution effect depends on the code.
- Click Submit.
After an environment variable with Continuously Effective selected changes, you can:
- Make the changed environment variables take effect for a specified component of the application by Upgrading a Single Component.
- Make the changed environment variables take effect for multiple or all components of the application by Upgrading Components in Batches.
Importing Environment Variables
The file must be a key-value pair mapping file in JSON or YAML format. A maximum of 200 environment variables can be imported at a time. Example file content and format:
{"key1": "value1", "key2": "value2"}
- key1 and key2 are the environment variable names, which must be unique in the same application environment. Enter 1 to 64 characters. Start with a letter, underscore (_), or hyphen (-). Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- value1 and value2 are the environment variable values.
Exercise caution when inputting sensitive information in configuring environment variables, or encrypt sensitive information to avoid information leakage.
- Log in to ServiceStage.
- Choose Application Management.
- Click the target application. The Overview page is displayed.
- In the left navigation pane, click Environment Variables.
- Select a created environment from the Environment drop-down list.
- Set the policy for the environment variables to take effect.
- First Time Effective: The environment variables take effect only when the component is created for the first time. Subsequent modifications to the environment variables will not be synchronized to the existing components of the application.
- Continuously Effective: The modification of environment variables will be synchronized to the existing components of the application through component upgrade.
- First Time Effective: The environment variables take effect only when the component is created for the first time. Subsequent modifications to the environment variables will not be synchronized to the existing components of the application.
- Click Import and select the created environment variable file.
- Click Submit.
After an environment variable with Continuously Effective selected changes, you can:
- Make the changed environment variables take effect for a specified component of the application by Upgrading a Single Component.
- Make the changed environment variables take effect for multiple or all components of the application by Upgrading Components in Batches.
Editing an Environment Variable
- Log in to ServiceStage.
- Choose Application Management.
- Click the target application. The Overview page is displayed.
- In the left navigation pane, click Environment Variables.
- Select a created environment from the Environment drop-down list.
- Set the policy for the environment variables to take effect.
- First Time Effective: The environment variables take effect only when the component is created for the first time. Subsequent modifications to the environment variables will not be synchronized to the existing components of the application.
- Continuously Effective: The modification of environment variables will be synchronized to the existing components of the application through component upgrade.
- First Time Effective: The environment variables take effect only when the component is created for the first time. Subsequent modifications to the environment variables will not be synchronized to the existing components of the application.
- Select the target variable and click Edit in the Operation column.
- Reset Name and Variable/Variable Reference.
Exercise caution when inputting sensitive information in configuring environment variables, or encrypt sensitive information to avoid information leakage.
- Name: environment variable name, which must be unique in the same environment. Enter 1 to 64 characters. Start with a letter, underscore (_), or hyphen (-). Only use letters, digits, underscores (_), hyphens (-), and periods (.).
- Variable/Variable Reference: environment variable value.
- Click Submit.
After an environment variable with Continuously Effective selected changes, you can:
- Make the changed environment variables take effect for a specified component of the application by Upgrading a Single Component.
- Make the changed environment variables take effect for multiple or all components of the application by Upgrading Components in Batches.
Deleting an Environment Variable
- Log in to ServiceStage.
- Choose Application Management.
- Click the target application. The Overview page is displayed.
- In the left navigation pane, click Environment Variables.
- Select a created environment from the Environment drop-down list.
- Single deletion: Select the target variable and click Delete in the Operation column.
Figure 1 Single deletion
- Batch deletion: Select the target variables and click Bulk Delete.
Figure 2 Batch deletion
- Single deletion: Select the target variable and click Delete in the Operation column.
- In the displayed dialog box, click OK.
After an environment variable with Continuously Effective selected changes, you can:
- Make the changed environment variables take effect for a specified component of the application by Upgrading a Single Component.
- Make the changed environment variables take effect for multiple or all components of the application by Upgrading Components in Batches.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot