Define a Value
Overview
You can define a new Value from the App Services UI or by importing an application directory that contains one or more Value configuration files. Select the tab below that corresponds to the method that you want to use.
Procedure
Create a New Value
You can define a new Value for your application in the App Services UI. To navigate to the Value configuration screen, click Values & Secrets in the left navigation menu. Ensure that the Values tab is selected and then click Create New Value.
Define the Value
Specify the Value Type. You can define two different types of Value: plain text and secret.
A plain text value is a string, array, or object that you define manually using standard JSON syntax.
To define a plain text value, select the Plain Text radio button and then enter the value in the input box.
A secret value exposes a Secret for use in Functions and rules.
To reference an existing Secret, select the Secret radio button and then select the name of the Secret that the value should reference from the Secret Name dropdown.
Alternatively, you can create and reference a new Secret by entering the new Secret's name in the Secret Name dropdown and then clicking Create. Enter the new Secret Value in the input box that appears.
Save the Value
After you have named and defined the new Value, click Save. Once saved, you can immediately access the Value in Functions and rules.
Add a Value Configuration File
Each Value is defined in its own JSON file in the values
subdirectory of your exported application. For example, a Value named
myValue
would be defined in the file /values/myValue.json
.
Add a configuration file for the new Value to the values
directory:
touch values/<Value Name>.json
The configuration file should have the following general form:
{ "name": "<Value Name>", "from_secret": <boolean>, "value": <Stored JSON Value|Secret Name> }
Field | Description |
---|---|
name | A unique name for the value. This name is how you refer to
the value in functions and rules. |
from_secret | |
value | The stored data that App Services exposes when the Value is referenced. If If |
Import Your Application Directory
Ensure that the Value configuration file is saved and then navigate to the root of your exported application directory. Log in to MongoDB Atlas with the App Services CLI:
appservices login --api-key="<my api key>" --private-api-key="<my private api key>"
Once you're logged in, import the directory:
appservices import
Once the import completes, you can immediately begin to access the Value in rules and functions.
Summary
You can use the App Services UI or App Services CLI to create and define App Services Values.