Configuration
This article explains how to configure a Cloud Function properly, both for local development and in the IXON Portal.
Cloud Functions can be used to integrate with external services. Most API's require credentials that need to be stored, which should not be hard-coded into your code, but instead configured using YAML.
Local development configuration
The configuration can be created locally by setting it in the context_values.yaml
file in the root of your backend-component-workspace
folder. There are no requirements on the format, other than that the root should be an object (i.e. not a string, array or number). This is the preferred place to put your credentials for development.
The context_values.yaml
file is not used if your Cloud Function runs in IXON Cloud. In IXON Cloud you can set the configuration in Admin > Apps > Function of choice > More options > Settings. The configuration set in Admin is stored encrypted.
NoteMake sure you use the same schema locally and in the cloud, or your Cloud Function may not work correctly.
Using the config during development
The configuration is made available through the FunctionContext
and can be used via the config
field as shown in the following snippet:
apiApplication: pubidxxxxxxx
externalService:
hostname: api.reallyusefulservice.com
username: user
password: pass
from ixoncdkingress.function.context import FunctionContext
@FunctionContext.expose
def hello_world(context: FunctionContext, **kwargs: Dict[str, str]):
# prints "pubidxxxxxxx"
print(context.config['apiApplication'])
# nested objects in the config are
# in nested dicts in the function:
# context.config['externalService']['username']
NoteKeep in mind that that numbers (integers and floats) are parsed as strings!
Default configuration
In order to help administrators with configuring your Cloud Function, you can provide a default configuration that will be copied upon install or share. It can be set in Studio > Cloud Functions > Function of choice > General > Default config. When this app is installed, users having the necessary permissions can change this default configuration in the Admin > Apps > Function of choice > More options.
You can use any valid YAML, so you are encouraged to make use of comments to clarify the various configuration options of your Cloud Function. For a short example, refer to the context_values.yaml
snippet shown in the previous section.
Keep your secrets safe!The default configuration is not encrypted and is shared with all users of your Cloud Function. It should therefore not contain secrets!
Confidentiality of the configuration
When setting the Default config for an app, you can also choose the confidentiality of the config, which can be set in Studio > Cloud Functions > Function of choice > Confidentiality > Edit. You want to be sure that secrets can only be accessed by the Cloud Function, so picking the Secret option in the following screenshot is recommended if you want to protect sensitive data:

Note about storing secrets!In Admin > Apps > Function of choice > More options > Settings you will be able to store your secrets safely so that only users that have the right permission will be able to see them. This will not be shared with other companies. For example: if Company A has stored credentials to access the Mail Form app in their Settings and Company B also installs it, Company B will then have to store their own credentials in the same section. Therefore, the two companies will not see each other's secrets.
Updated about 3 hours ago