# ContainerEnvVarConstruct

- Kind: `class`
- Package: [Aspire.Hosting.Radius](/reference/api/csharp/aspire.hosting.radius.md)
- Version: `17.0.0-preview.1.26567.5`
- Namespace: `Aspire.Hosting.Radius.Publishing.Constructs`
- Target framework: `net10.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/2d325b13709752ba6d9a943635c5e2940a2530c0/src/Aspire.Hosting.Radius/Publishing/Constructs/ContainerEnvVarConstruct.cs)
- Inherits: `ProvisionableConstruct`

Represents a single environment-variable entry in a container's `env` block.

## Definition

```csharp
namespace Aspire.Hosting.Radius.Publishing.Constructs;

public sealed class ContainerEnvVarConstruct
    : Azure.Provisioning.Primitives.ProvisionableConstruct
{
    // ...
}
```

## Remarks

The Radius container schema models `env` as a map keyed by the variable name, where each entry is an object carrying either a `value` or a `valueFrom` source. The two forms are mutually exclusive: assign [ContainerEnvVarConstruct.Value](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/properties.md#value) or the [ContainerEnvVarConstruct.SecretName](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/properties.md#secretname) / [ContainerEnvVarConstruct.SecretKey](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/properties.md#secretkey) pair, never both.

The `value` form is emitted for values that carry nothing sensitive. It ends up verbatim in the Kubernetes `Deployment` spec, so a credential emitted this way is readable by anyone who can read the Deployment or its rollout history -- even when the Bicep composed it from an `@secure()` parameter, which only keeps it out of the published artifact.

The `valueFrom.secretKeyRef` form points at a key of a `Radius.Security/secrets` resource; `secretName` is that resource's name, which the secrets recipe also uses as the Kubernetes `Secret` name. The container recipe emits these entries ahead of the plain `value` ones so kubelet's `$(VAR)` expansion can reference them.

See: https://github.com/radius-project/radius/blob/main/eng/design-notes/extensibility/2025-08-container-resource-type.md and Compute/containers/containers.yaml in radius-project/resource-types-contrib.

## Constructors

- [ContainerEnvVarConstruct](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/constructors.md#constructor)

## Properties

- [SecretKey](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/properties.md#secretkey) : `BicepValue<string>` `get; set` -- The key within the secret resource's `data` map. Emitted only when assigned, and mutually exclusive with [ContainerEnvVarConstruct.Value](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/properties.md#value).
- [SecretName](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/properties.md#secretname) : `BicepValue<string>` `get; set` -- The name of the `Radius.Security/secrets` resource supplying this value. Emitted only when assigned, and mutually exclusive with [ContainerEnvVarConstruct.Value](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/properties.md#value).
- [Value](/reference/api/csharp/aspire.hosting.radius/containerenvvarconstruct/properties.md#value) : `BicepValue<string>` `get; set` -- The environment variable value (a literal, or a reference to a Bicep parameter).
