microsoft/aspire · error · NotSupportedException

Resource ' ' cannot be deployed to Azure sandbox group ' '…

Error message

Resource '{resource.TargetResource.Name}' cannot be deployed to Azure sandbox group '{resource.Parent.Name}' because it does not produce or reference a container image.

What it means

If the target resource neither requires build/push nor exposes a resolvable container image name (TryGetContainerImageName fails), the deployment cannot determine any image to run and throws NotSupportedException. Only resources that produce or reference a container image are deployable to a sandbox group.

Solutions

  1. Ensure the resource is containerized: use AddDockerfile/AddContainer or enable container build for the project so it carries an image annotation.
  2. Pass an explicit image name/tag to AddContainer so TryGetContainerImageName succeeds.
  3. Check custom PipelineStepConfiguration callbacks for steps that remove or overwrite ContainerImageAnnotation on the resource.
  4. Remove non-container resources from the sandbox group; they are not supported by this integration.

Example fix

// before
var svc = builder.AddProject<Projects.Worker>("worker"); // executable resource, no image
builder.AddAzureSandboxGroup("group").AddResource(svc);

// after
var svc = builder.AddContainer("worker", "myregistry.azurecr.io/worker:latest"); // explicit image reference
Defensive patterns

Strategy: validation

Validate before calling

if (!resource.TargetResource.RequiresImageBuildAndPush() &&
    !resource.TargetResource.TryGetContainerImageName(out _))
{
    throw new NotSupportedException($"{resource.TargetResource.Name} must be a container resource for sandbox deployment.");
}

Prevention

When it happens

Trigger: Adding a non-container resource (e.g. an executable/project without container image support, or a resource where image metadata was stripped by a transform) as a child of a sandbox group and running the sandbox publish/deploy pipeline.

Common situations: Deploying an executable resource (AddProject without docker targeting) or a custom IResource type into a sandbox group; misconfigured ContainerImageAnnotation removed by a custom pipeline callback; using a bait-and-switch resource swap that replaced the container resource with one lacking image metadata.

Understand the failure class

Background: "is not a compatible type" / "cannot merge" errors: when a value's type doesn't match what the library requires — this error's family across 65 libraries.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/8a974a236f043f37. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:988

    }

    private static async Task<string> ResolveContainerImageAsync(PipelineStepContext context, AzureSandboxContainerResource resource)
    {
        if (resource.TargetResource.RequiresImageBuildAndPush())
        {
            var containerImageReference = new ContainerImageReference(resource.TargetResource);
            return await ((IValueProvider)containerImageReference)
                .GetValueAsync(new ValueProviderContext { ExecutionContext = context.ExecutionContext, Caller = resource.TargetResource }, context.CancellationToken)
                .ConfigureAwait(false)
                ?? throw new InvalidOperationException($"Could not resolve the pushed container image for resource '{resource.TargetResource.Name}'.");
        }

        if (resource.TargetResource.TryGetContainerImageName(out var imageName))
        {
            return imageName;
        }

        throw new NotSupportedException($"Resource '{resource.TargetResource.Name}' cannot be deployed to Azure sandbox group '{resource.Parent.Name}' because it does not produce or reference a container image.");
    }

    private static async Task<string> ResolveContainerImageReferenceForDiskImageAsync(PipelineStepContext context, string imageReference)
    {
        var runtime = await ResolveContainerRuntimeAsync(context).ConfigureAwait(false);
        return await ResolveContainerImageReferenceForDiskImageAsync(
            runtime,
            imageReference,
            context.CancellationToken).ConfigureAwait(false);
    }

    internal static async Task<string> ResolveContainerImageReferenceForDiskImageAsync(
        IContainerRuntime runtime,
        string imageReference,
        CancellationToken cancellationToken)
    {
        ArgumentNullException.ThrowIfNull(runtime);
        ArgumentException.ThrowIfNullOrWhiteSpace(imageReference);

View on GitHub (pinned to 25830f84bd)