# VolumeMountBindingAnnotation

- Kind: `class`
- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Version: `13.6.0`
- Namespace: `Aspire.Hosting.ApplicationModel`
- Target framework: `net10.0`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/f4c27f2d43ddc1cacd0dd083b30d1fea1cee7a62/src/Aspire.Hosting/ApplicationModel/VolumeMountBindingAnnotation.cs)
- Implements: [IResourceAnnotation](/reference/api/csharp/aspire.hosting/iresourceannotation.md)

Describes how a named volume binds to a resource across the inner and outer loop.

## Definition

```csharp
namespace Aspire.Hosting.ApplicationModel;

public sealed class VolumeMountBindingAnnotation
    : Aspire.Hosting.ApplicationModel.IResourceAnnotation
{
    // ...
}
```

## Remarks

This annotation is the extensibility point compute environments use to participate in the portable volume path convention. It carries two independent facets, either of which may be absent:

- [VolumeMountBindingAnnotation.EnvironmentVariableName](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#environmentvariablename) records that the workload reads the effective storage path from an environment variable. The variable itself is written by an [EnvironmentCallbackAnnotation](/reference/api/csharp/aspire.hosting/environmentcallbackannotation.md) whose closure captures the name, which makes the intent invisible to anything inspecting the model. Restating it here lets a compute environment tell whether a host process materializes a local backing store for the volume, without having to observe the callback running.
- [VolumeMountBindingAnnotation.RunModeHostPathResolver](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#runmodehostpathresolver) lets a compute environment supply the local directory that backs the volume in run mode. Without it, host processes fall back to a workload-scoped directory under [IAspireStore](/reference/api/csharp/aspire.hosting/iaspirestore.md).

The two facets are produced by different parties at different times -- the AppHost author opts into the environment variable, while the compute environment supplies the local path -- so a resource can carry several of these annotations for the same [VolumeMountBindingAnnotation.VolumeName](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#volumename). A binding resolves through its own [VolumeMountBindingAnnotation.RunModeHostPathResolver](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#runmodehostpathresolver) when it has one, and otherwise takes the last sibling that does. [VolumeMountBindingAnnotation.VolumeName](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#volumename) alone is not a unique key, because separate compute environments can each declare a volume under the same name.

## Constructors

- [VolumeMountBindingAnnotation(string)](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/constructors.md#constructor-string) -- Describes how a named volume binds to a resource across the inner and outer loop.

## Properties

- [EnvironmentVariableName](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#environmentvariablename) : `string?` `get; init` -- Gets the environment variable that receives the effective storage path, or `null` when this binding only supplies a run-mode path.
- [MountPath](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#mountpath) : `string?` `get; init` -- Gets the path the volume is mounted at once deployed, or `null` when this binding only supplies a run-mode path for a mount declared elsewhere.
- [RunModeHostPathResolver](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#runmodehostpathresolver) : `Func<EnvironmentCallbackContext, string>` `get; init` -- Gets a callback that returns the local host directory backing the volume in run mode, or `null` to use the default workload-scoped directory under [IAspireStore](/reference/api/csharp/aspire.hosting/iaspirestore.md).
- [VolumeName](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/properties.md#volumename) : `string` `get` -- Gets the name of the volume this binding applies to.

## Methods

- [ResolvePath(EnvironmentCallbackContext)](/reference/api/csharp/aspire.hosting/volumemountbindingannotation/methods.md#resolvepath-environmentcallbackcontext) : `string` -- Resolves the storage path the workload should use for the current execution mode.
