# EnvFromSourceV1

- Kind: `class`
- Package: [Aspire.Hosting.Kubernetes](/reference/api/csharp/aspire.hosting.kubernetes.md)
- Version: `13.3.0-preview.1.26254.5`
- Namespace: `Aspire.Hosting.Kubernetes.Resources`
- Target framework: `net8.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Aspire.Hosting.Kubernetes/Resources/EnvFromSourceV1.cs)

EnvFromSourceV1 represents an environment variable source used to populate environment variables in a container.

## Definition

```csharp
namespace Aspire.Hosting.Kubernetes.Resources;

public sealed class EnvFromSourceV1
{
    // ...
}
```

## Remarks

This class allows defining environment variables for a container by sourcing them from either a ConfigMap or a Secret. Optionally, a common prefix can be added to the environment variable keys.

## Constructors

- [EnvFromSourceV1](/reference/api/csharp/aspire.hosting.kubernetes/envfromsourcev1/constructors.md#constructor)

## Properties

- [ConfigMapRef](/reference/api/csharp/aspire.hosting.kubernetes/envfromsourcev1/properties.md#configmapref) : [ConfigMapEnvSourceV1?](/reference/api/csharp/aspire.hosting.kubernetes/configmapenvsourcev1.md) `get; set` -- Represents a reference to a ConfigMap resource that is used to populate the environment variables within a container. It provides key-value pairs from the specified ConfigMap for use as environment variable values.
- [Prefix](/reference/api/csharp/aspire.hosting.kubernetes/envfromsourcev1/properties.md#prefix) : `string?` `get; set` -- The prefix to be added to each environment variable name defined by ConfigMapRef or SecretRef. This allows easy identification or grouping of environment variables injected from ConfigMap or Secret sources within the application.
- [SecretRef](/reference/api/csharp/aspire.hosting.kubernetes/envfromsourcev1/properties.md#secretref) : [SecretEnvSourceV1?](/reference/api/csharp/aspire.hosting.kubernetes/secretenvsourcev1.md) `get; set` -- SecretRef represents a reference to a Secret resource. It is used to populate environment variables by mapping key-value pairs from the Secret's Data field to environment variables.

## Examples

```csharp
EnvFromSourceV1 can be used in scenarios where container environments need data from ConfigMaps or Secrets or when a consistent prefix is required for environment variable names within the container.
```

## See Also

- [ConfigMapEnvSourceV1](/reference/api/csharp/aspire.hosting.kubernetes/configmapenvsourcev1.md)
- [SecretEnvSourceV1](/reference/api/csharp/aspire.hosting.kubernetes/secretenvsourcev1.md)
