> ## Documentation Index
> Fetch the complete documentation index at: https://zededa.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Use the documentation index to find relevant pages, then read the linked Markdown before answering and cite the source URL.
> Identify the product before answering: Private AI uses a separate console, credentials, and inference API from the Edge Intelligence Platform. Do not apply instructions from one product to the other.
> Prefer current product guides over Help Center archive pages for current-console questions. Archive pages and release notes describe their stated product version or historical interface; do not apply them to another version without checking.
> Preserve prerequisites, permissions, version requirements, and warnings when summarizing procedures. Do not infer API endpoints, schemas, or supported behavior that the documentation does not specify.

# Add Environment Variables to Applications

> Pass environment variables to container and VM application instances using the custom configuration system in Edge Infrastructure Services.

## Introduction

Environment variables let you pass configuration values to your application at runtime without modifying the container image. In Edge Infrastructure Services, environment variables for application instances are delivered through the custom configuration mechanism using the cloud-init standard.

This procedure covers two approaches:

* **Key-value pairs**: pass simple `VARIABLE_NAME=VALUE` pairs to the application as environment variables.
* **File injection**: write a file (for example, a certificate or configuration file) to the container filesystem before startup.

For background on how custom configuration works, see [Custom Configuration for Applications](https://zededa.mintlify.site/new-ui/marketplace/custom-app-configuration.md).

### Prerequisites

* You have the SysManager or SysAdmin role in your enterprise. See [Manage Roles](https://zededa.mintlify.site/new-ui/infrastructure-services/administration/manage-roles.md).
* You are working with a Container or VM app type. Docker Compose environment variables are handled through the compose file.

## How Environment Variables Are Delivered

EVE-OS (Edge Virtualization Engine) delivers cloud-init configuration to application instances when they start.

**For container instances**, EVE-OS parses the custom configuration and applies it directly (no cloud-init daemon required in the container):

* **Simple key-value format**: use `VARIABLE_NAME=VALUE` pairs, one per line. This is the legacy format supported across all EVE-OS LTS versions.
* **Cloud-init format**: use the standard cloud-init `runcmd` field to set environment variables, and optionally `write_files` to inject files. Available since EVE-OS 11.3.

**For VM instances**, EVE-OS uses the NoCloud data source to provide the configuration to the VM via a virtual CD-ROM. The VM must have cloud-init installed and running to consume it.

## Set Up Environment Variables in the App Image

Environment variables passed via custom configuration are defined as part of the edge app image. Add the custom configuration template and variable groups to the app image before deploying any instances.

1. Navigate to **Infrastructure > Workloads > Build > App Images**.
2. Open the app image or click **Add Image** to create a new one.
3. In the **Custom Configuration** section, enable custom configuration.
4. Add a variable group to hold your environment variable definitions.
5. For each environment variable you want to expose:
   * Add a variable of type **Text** or **Password** (for sensitive values).
   * Set the **Name** to the variable identifier used in the template (for example, `API_KEY`).
   * Set the **Label** to a user-friendly name (for example, "API Key").
   * Mark it as **Required** if a value must always be provided.
6. In the **Configuration Template**, enter the cloud-init content that sets the environment variables. Use the field delimiter to reference each variable. For example, if the delimiter is `###`:

```
###API_KEY###=###API_KEY###
DATABASE_HOST=###DATABASE_HOST###
```

For VM instances, the template must begin with `#cloud-config`:

```yaml theme={"dark"}
#cloud-config
runcmd:
  - API_KEY=###API_KEY###
  - DATABASE_HOST=###DATABASE_HOST###
```

7. Save the app image.

## Inject a File into a Container

To write a file (for example, a certificate) to the container filesystem, use the `write_files` cloud-init directive in the configuration template.

1. In the app image's custom configuration, add a variable of type **File** named `CERT_CONTENT` (or a name appropriate for your use case).
2. In the **Configuration Template**, reference the variable in a `write_files` block:

```yaml theme={"dark"}
#cloud-config
write_files:
  - path: /etc/myapp/server.cert.pem
    permissions: '0644'
    encoding: b64
    content: ###CERT_CONTENT###
```

At deploy time, the user provides the base64-encoded certificate content. EVE-OS writes the decoded file to `/etc/myapp/server.cert.pem` before starting the container.

## Supply Variable Values at Deploy Time

When you deploy an instance from the app image, the **Custom Config** step in the wizard prompts for the values of each variable you defined.

1. Navigate to **Infrastructure > Workloads > Applications**.
2. Select the contextual **+** create action and select the app image.
3. Complete the **App & Target** and **Interfaces** steps.
4. In the **Custom Config** step, enter values for each environment variable.
5. Complete the wizard and click **Create Application**.

The values are delivered to the instance when it starts.

## Update Environment Variables

After an instance is deployed, changing environment variable values requires a restart or reactivation to take effect:

* If the app image allows configuration override, click the **Configure** (gear) icon on the instance detail page to update the values.
* Changes to the variable groups themselves (adding, removing, or renaming variables) require deleting and redeploying the instance with the updated configuration.

## Use a System Variable

Edge Infrastructure Services provides built-in system variables that are automatically replaced with platform values at deploy time. For example, you can include the node name in the configuration without knowing it at authoring time. Refer to the custom configuration settings in the app image for the list of available system variables and their syntax.

## Next Steps

> [card] [Custom Configuration for Applications](https://zededa.mintlify.site/new-ui/marketplace/custom-app-configuration.md)
>
> The full custom configuration reference, including all variable types and template syntax.

> [card] [Deploy an Application Instance](https://zededa.mintlify.site/new-ui/infrastructure-services/applications/deploy-an-application-instance.md)
>
> The full deployment wizard walkthrough.

> [card] [Add an Edge App Image](https://zededa.mintlify.site/new-ui/infrastructure-services/build-and-library/add-an-edge-app-image.md)
>
> Create a new app image with environment variable support.
