How to add environment variables to edge applications

To make a user-defined environment variable accessible to your edge application, you must add a key-value pair to your application's custom configuration.

In addition to simple key-value pairs, e.g. "<KEY_NAME>=<VALUE_NAME>", you can also add a file as a key's value - for example, a certificate.

Procedures

Add a key-value pair

To add an environment variable to an edge application's container instance, you must enter the variable and its value into your application's custom configuration file.

In the custom configuration file, enter your "VARIABLE_NAME" and "VARIABLE_VALUE" using the following syntax. Replace "VARIABLE_NAME" and "VARIABLE_VALUE" with the appropriate values.

<VARIABLE_NAME>=<VARIABLE_VALUE>

Add a file

  1. Navigate to the Configuration block, in the main page when adding an edge app instance.
  2. Click on Yes under Add Custom Config Template.
  3. Click on Add Variables Groups.
  4. Click on Add Variable.
  5. Set the variable type as File.
  6. Enter your Variable Name.
  7. In the custom Configuration Template, enter a write-file section similar the following:
    write_files: 
    - path: /etc/mydirectory/mycertificate.cert.pem
      permissions: '0644'
      encoding: b64
      content: ###identity_cert###
    The contents of the file will be written to the file provided under "path". The file can then be used in the cloud-init configuration script.
Was this article helpful?
1 out of 1 found this helpful

Articles in this section

See more