microsoft/aspire · error · DistributedApplicationException
Resource ' ' binds different Kubernetes persistent volumes…
Error message
Resource '{resourceGroup.Key.Name}' binds {volumes.Length} different Kubernetes persistent volumes named '{nameGroup.Key}' (from environments {environmentNames}). Run mode resolves both the local path and the container volume by name, so these would share one backing store. Publishing rejects this shape as well, because two resources cannot share the name '{nameGroup.Key}'. Give the volumes distinct names. What it means
A single resource binds multiple distinct Kubernetes persistent volumes that share the same name (declared in different environments). Run mode resolves both the local path and container volume purely by name, so the two volumes would collide on one backing store; publish mode also rejects duplicate volume names. The validator throws DistributedApplicationException.
Solutions
- Give the two persistent volumes distinct names (e.g. 'data-dev' and 'data-prod').
- Bind the workload to only one of the conflicting environments/volumes.
- Consolidate the volume declarations into a single Kubernetes environment.
Example fix
// before
env1.AddPersistentVolume("data", ...);
env2.AddPersistentVolume("data", ...); // duplicate name
// after
env1.AddPersistentVolume("data-dev", ...);
env2.AddPersistentVolume("data-prod", ...); Defensive patterns
Strategy: validation
Validate before calling
var dupes = volumes.GroupBy(v => v.Name).Where(g => g.Count() > 1); if (dupes.Any()) throw new Exception($"Duplicate volume names: {string.Join(',', dupes.Select(g => g.Key))}"); Try / catch
try { RunAppHostAsync(); } catch (DistributedApplicationException ex) when (ex.Message.Contains("different Kubernetes persistent volumes named")) { /* rename conflicting volumes */ } Prevention
- Give volumes unique names across all environments
- Avoid copy-pasting volume declarations across environments
- Centralize volume naming with constants or a factory
When it happens
Trigger: A workload (via WithComputeEnvironment/WithPersistentVolume) binds two Kubernetes persistent volumes with identical names declared under two different Kubernetes environments, then running or publishing the AppHost.
Common situations: Multi-environment AppHosts (e.g. 'dev' and 'prod' Kubernetes environments) where volumes were copy-pasted with the same name and one workload references both.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Kubernetes persistent volume
- Resource ' ' cannot resolve the ' ' persistent-volume path…
- Bind mounts are not supported by the Kubernetes publisher
- Resource ' ' is assigned to compute environment ' ' but…
- Unsupported storage type
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/83cd958bda222ee0.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Kubernetes/KubernetesEnvironmentExtensions.cs:151
//
// Both run-mode paths key off the volume name alone — the local path lookup in
// VolumeMountBindingAnnotation.ResolvePath and the container mount rewrite in
// ApplyRunModeContainerVolumeName — so two distinct volumes sharing a name on one resource would
// silently resolve to a single backing store and mix their data. Reject that rather than teach
// both paths to disambiguate, because the shape can never be published: whichever local
// behavior we chose would only work in the inner loop.
foreach (var resourceGroup in bindings.GroupBy(item => item.Resource))
{
foreach (var nameGroup in resourceGroup.GroupBy(
item => item.Annotation.Volume.Name,
StringComparer.OrdinalIgnoreCase))
{
var volumes = nameGroup.Select(item => item.Annotation.Volume).Distinct().ToArray();
if (volumes.Length > 1)
{
var environmentNames = string.Join(", ", volumes.Select(volume => $"'{volume.Parent.Name}'"));
throw new DistributedApplicationException(
$"Resource '{resourceGroup.Key.Name}' binds {volumes.Length} different Kubernetes persistent volumes named '{nameGroup.Key}' (from environments {environmentNames}). " +
$"Run mode resolves both the local path and the container volume by name, so these would share one backing store. " +
$"Publishing rejects this shape as well, because two resources cannot share the name '{nameGroup.Key}'. Give the volumes distinct names.");
}
}
}
}
private static void ValidateRunModeBackingStoreCompatibility(PersistentVolumeBinding[] bindings)
{
// Host processes use an IAspireStore directory while containers use a named runtime
// volume. Treating those as one logical volume would silently split the data in run mode.
foreach (var environmentGroup in bindings.GroupBy(
item => item.Annotation.Volume.Parent.Name,
StringComparer.OrdinalIgnoreCase))
{
foreach (var volumeGroup in environmentGroup.GroupBy(
item => item.Annotation.Volume.Name,View on GitHub (pinned to 25830f84bd)