microsoft/aspire · error · InvalidOperationException
Could not resolve the pushed container image for resource
Error message
Could not resolve the pushed container image for resource '{resource.TargetResource.Name}'. What it means
When the target resource requires image build and push, the deployment resolves its pushed image reference via ContainerImageReference. If that value provider returns null, the deployment cannot determine what image to run in the sandbox and throws. The thrown object is the null-coalescing result, so the surfaced message is this string.
Solutions
- Ensure the deployment pipeline includes the image build-and-push steps before the sandbox deploy step and that they succeeded.
- Verify the container registry configuration (registry URL, credentials) so the image can be pushed and referenced.
- Run the deploy in publish mode with a valid execution context (aspire publish/deploy) rather than run mode.
- If using a pre-built image, make the resource reference a concrete image name so RequiresImageBuildAndPush is not needed.
Example fix
// before aspire deploy --skip-build // image never pushed, reference resolves to null // after aspire publish && aspire deploy // build/push completes first, ContainerImageReference resolves
Defensive patterns
Strategy: validation
Validate before calling
if (resource.TargetResource.RequiresImageBuildAndPush())
{
// Ensure publish/build steps ran before deploy
var pushed = await TryResolvePushedImageAsync(resource.TargetResource);
if (pushed is null) throw new InvalidOperationException("Run 'aspire publish' (build+push) before deploy.");
} Prevention
- Always run publish (build+push) before deploy in CI pipelines.
- Verify registry credentials and configuration before deploying.
- Check the push step's logs for silent failures.
When it happens
Trigger: Deploying a project/container resource whose TargetResource.RequiresImageBuildAndPush() is true, but the ContainerImageReference value provider yields null during GetValueAsync — typically because the image was never built/pushed (publish step skipped or failed) or the execution context lacks publish metadata.
Common situations: Running a sandbox deploy without a preceding container build/publish step; a failed or skipped push in the pipeline leaving no registry image; misconfigured registry so the push produced no reference; calling deploy in run-mode context where no push occurred.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Resource ' ' cannot be deployed to Azure sandbox group ' '…
- An Azure principal parameter was not supplied a value…
- App Service configuration validation failed. See errors…
- ASPIRERADIUS011
- Azure Container App environments
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/f68cc0cfdadc6e2d.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.Sandboxes/AzureSandboxContainerDeployment.cs:980
{
EntraId = new AzureDevComputePortEntraIdAuthConfig
{
Enabled = true,
ObjectIds = [],
TenantIds = []
}
};
}
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);
}View on GitHub (pinned to 25830f84bd)