# EnvironmentCallbackContext Properties

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [EnvironmentCallbackContext](/reference/api/csharp/aspire.hosting/environmentcallbackcontext.md)
- Kind: `Properties`
- Members: `5`

Represents a callback context for environment variables associated with a publisher.

## CancellationToken

- Name: `CancellationToken`
- Modifiers: `get`
- Returns: `CancellationToken`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackContext.cs#L42)

Gets the CancellationToken associated with the callback context.

```csharp
public CancellationToken CancellationToken { get; }
```

## EnvironmentVariables

- Name: `EnvironmentVariables`
- Modifiers: `get`
- Returns: `Dictionary<string, object>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackContext.cs#L37)

Gets the environment variables associated with the callback context.

```csharp
public Dictionary<string, object> EnvironmentVariables { get; }
```

## ATS metadata

### ATS union

- Accepted types: `string` | [ReferenceExpression](/reference/api/csharp/aspire.hosting/referenceexpression.md)

## ExecutionContext

- Name: `ExecutionContext`
- Modifiers: `get`
- Returns: [DistributedApplicationExecutionContext](/reference/api/csharp/aspire.hosting/distributedapplicationexecutioncontext.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackContext.cs#L75)

Gets the execution context associated with this invocation of the AppHost.

```csharp
public DistributedApplicationExecutionContext ExecutionContext { get; }
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## Logger

- Name: `Logger`
- Modifiers: `get; set`
- Returns: `ILogger`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackContext.cs)

An optional logger to use for logging.

```csharp
public ILogger Logger { get; set; }
```

## Resource

- Name: `Resource`
- Modifiers: `get`
- Returns: [IResource](/reference/api/csharp/aspire.hosting/iresource.md)
- Source: [GitHub](https://github.com/microsoft/aspire/blob/bd20f904cde09ecb9c9ae5116a6f13614bf2d7c2/src/Aspire.Hosting/ApplicationModel/EnvironmentCallbackContext.cs#L69)

The resource associated with this callback context.

```csharp
public IResource Resource { get; }
```

## Exceptions

- `InvalidOperationException` -- Thrown when the EnvironmentCallbackContext was created without a specified resource.

## Remarks

This will be set to the resource in all cases where Aspire invokes the callback.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
