{"record":{"id":"8a974a236f043f37","repo":"microsoft/aspire","slug":"resource-resource-targetresource-name-cannot-be-deployed-to","errorCode":null,"errorMessage":"Resource '{resource.TargetResource.Name}' cannot be deployed to Azure sandbox group '{resource.Parent.Name}' because it does not produce or reference a container image.","messagePattern":"Resource '(.+?)' cannot be deployed to Azure sandbox group '(.+?)' because it does not produce or reference a container image\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs","lineNumber":988,"sourceCode":"    }\n\n    private static async Task<string> ResolveContainerImageAsync(PipelineStepContext context, AzureSandboxContainerResource resource)\n    {\n        if (resource.TargetResource.RequiresImageBuildAndPush())\n        {\n            var containerImageReference = new ContainerImageReference(resource.TargetResource);\n            return await ((IValueProvider)containerImageReference)\n                .GetValueAsync(new ValueProviderContext { ExecutionContext = context.ExecutionContext, Caller = resource.TargetResource }, context.CancellationToken)\n                .ConfigureAwait(false)\n                ?? throw new InvalidOperationException($\"Could not resolve the pushed container image for resource '{resource.TargetResource.Name}'.\");\n        }\n\n        if (resource.TargetResource.TryGetContainerImageName(out var imageName))\n        {\n            return imageName;\n        }\n\n        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.\");\n    }\n\n    private static async Task<string> ResolveContainerImageReferenceForDiskImageAsync(PipelineStepContext context, string imageReference)\n    {\n        var runtime = await ResolveContainerRuntimeAsync(context).ConfigureAwait(false);\n        return await ResolveContainerImageReferenceForDiskImageAsync(\n            runtime,\n            imageReference,\n            context.CancellationToken).ConfigureAwait(false);\n    }\n\n    internal static async Task<string> ResolveContainerImageReferenceForDiskImageAsync(\n        IContainerRuntime runtime,\n        string imageReference,\n        CancellationToken cancellationToken)\n    {\n        ArgumentNullException.ThrowIfNull(runtime);\n        ArgumentException.ThrowIfNullOrWhiteSpace(imageReference);","sourceCodeStart":970,"sourceCodeEnd":1006,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs#L970-L1006","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the resource is containerized: use AddDockerfile/AddContainer or enable container build for the project so it carries an image annotation.","Pass an explicit image name/tag to AddContainer so TryGetContainerImageName succeeds.","Check custom PipelineStepConfiguration callbacks for steps that remove or overwrite ContainerImageAnnotation on the resource.","Remove non-container resources from the sandbox group; they are not supported by this integration."],"exampleFix":"// before\nvar svc = builder.AddProject<Projects.Worker>(\"worker\"); // executable resource, no image\nbuilder.AddAzureSandboxGroup(\"group\").AddResource(svc);\n\n// after\nvar svc = builder.AddContainer(\"worker\", \"myregistry.azurecr.io/worker:latest\"); // explicit image reference","handlingStrategy":"validation","validationCode":"if (!resource.TargetResource.RequiresImageBuildAndPush() &&\n    !resource.TargetResource.TryGetContainerImageName(out _))\n{\n    throw new NotSupportedException($\"{resource.TargetResource.Name} must be a container resource for sandbox deployment.\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only add container-backed resources (AddContainer/AddDockerfile or containerized projects) to sandbox groups.","Supply explicit image names for pre-built images.","Review custom pipeline callbacks for code that strips ContainerImageAnnotation."],"tags":["azure","containers","image","sandbox"],"backgroundTag":"incompatible-source-type","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}