# EnvironmentCallbackAnnotation Constructors

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [EnvironmentCallbackAnnotation](/reference/api/csharp/aspire.hosting/environmentcallbackannotation.md)
- Kind: `Constructors`
- Members: `4`

Represents an annotation that provides a callback to modify the environment variables of an application.

## EnvironmentCallbackAnnotation(string, Func<string>)

- Name: `Constructor(string, Func<string>)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackAnnotation.cs#L18-L36)

Initializes a new instance of the [EnvironmentCallbackAnnotation](/reference/api/csharp/aspire.hosting/environmentcallbackannotation.md) class with the specified name and callback function.

```csharp
public class EnvironmentCallbackAnnotation
{
    public EnvironmentCallbackAnnotation(
        string name,
        Func<string> callback)
    {
        // ...
    }
}
```

## Parameters

- `name` (`string`)
  The name of the environment variable to set.
- `callback` (`Func<string>`)
  The callback function that returns the value to set the environment variable to.

## EnvironmentCallbackAnnotation(Action<Dictionary<string, object>>)

- Name: `Constructor(Action<Dictionary<string, object>>)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackAnnotation.cs)

Initializes a new instance of the [EnvironmentCallbackAnnotation](/reference/api/csharp/aspire.hosting/environmentcallbackannotation.md) class with the specified callback action.

```csharp
public class EnvironmentCallbackAnnotation
{
    public EnvironmentCallbackAnnotation(
        Action<Dictionary<string, object>> callback)
    {
        // ...
    }
}
```

## Parameters

- `callback` (`Action<Dictionary<string, object>>`)
  The callback action to be executed.

## EnvironmentCallbackAnnotation(Action<EnvironmentCallbackContext>)

- Name: `Constructor(Action<EnvironmentCallbackContext>)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackAnnotation.cs)

Initializes a new instance of the [EnvironmentCallbackAnnotation](/reference/api/csharp/aspire.hosting/environmentcallbackannotation.md) class with the specified callback.

```csharp
public class EnvironmentCallbackAnnotation
{
    public EnvironmentCallbackAnnotation(
        Action<EnvironmentCallbackContext> callback)
    {
        // ...
    }
}
```

## Parameters

- `callback` (`Action<EnvironmentCallbackContext>`)
  The callback to be invoked.

## EnvironmentCallbackAnnotation(Func<EnvironmentCallbackContext, Task>)

- Name: `Constructor(Func<EnvironmentCallbackContext, Task>)`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackAnnotation.cs)

Initializes a new instance of the [EnvironmentCallbackAnnotation](/reference/api/csharp/aspire.hosting/environmentcallbackannotation.md) class with the specified callback.

```csharp
public class EnvironmentCallbackAnnotation
{
    public EnvironmentCallbackAnnotation(
        Func<EnvironmentCallbackContext, Task> callback)
    {
        // ...
    }
}
```

## Parameters

- `callback` (`Func<EnvironmentCallbackContext, Task>`)
  The callback to be invoked.
