microsoft/aspire · error · InvalidOperationException
("rad deploy failed with exit code " or "rad deploy failed…
Error message
{errorMessage} ("rad deploy failed with exit code {exitCode}" or "rad deploy failed with exit code {exitCode}: {stderrText}") What it means
After launching `rad deploy`, the step waits for exit. A non-zero exit code means the Radius deployment failed; the step composes an error message (with or without captured stderr), logs it, reports it to the publishing context, and throws an InvalidOperationException.
Solutions
- Read the stderr portion of the message — it contains rad's actual deployment error; fix that root cause.
- Run `rad deploy <app.bicep>` manually against the same environment to see full output.
- Verify the environment's recipes and parameters match what the generated app.bicep requests.
- Fix any ASPIRERADIUS diagnostic errors (e.g. removed secrets) that would make the Bicep invalid before deploying.
Example fix
// before
// rad deploy failed with exit code 1: recipe 'redis' not found in environment
// after (shell)
rad recipe list # confirm available recipes, then align the resource's recipe name
builder.AddRedis("cache").WithRecipe("redis-recipe"); Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-deploy sanity checks: environment reachable and Bicep exists
var bicepPath = Path.Combine(outputDir, "app.bicep");
if (!File.Exists(bicepPath)) throw new InvalidOperationException("Run publish before deploy.");
// and confirm recipes referenced by the model exist:
// rad recipe list --environment <env> Try / catch
try { await deployStep.ExecuteAsync(context, ct); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("rad deploy failed"))
{
// The stderr portion of the message holds rad's actual error — surface it
logger.LogError(ex, "Radius deployment failed; see embedded stderr for root cause.");
} Prevention
- Fix any ASPIRERADIUS diagnostics before deploying — rejected Bicep is the most common cause
- Verify recipe names and parameters in the generated app.bicep against `rad recipe list`
- Confirm control-plane connectivity and authentication before deploy
- Test `rad deploy app.bicep` manually once to see full rad output
When it happens
Trigger: rad deploy exits non-zero: invalid or rejected app.bicep, recipe/parameter mismatches, Radius control plane errors, Kubernetes resource creation failures, or missing credentials — with stderrText present when stderr was captured.
Common situations: Bicep referencing a recipe that does not exist in the environment; quota or RBAC failures in the target cluster; the app.bicep generated from callbacks (e.g. removed secrets) being rejected by Radius; network/auth failures to the control plane.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- Bicep file not found at
- rad credential register failed with exit code
- A ConfigureRadiusInfrastructure callback renamed container
- A ConfigureRadiusInfrastructure callback replaced container
- A ConfigureRadiusInfrastructure callback replaced port
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/2a0c76903f9b5886.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Radius/Publishing/RadiusDeploymentPipelineStep.cs:637
throw;
}
var exitCode = process.ExitCode;
logger.LogInformation("rad deploy exited with code {ExitCode} for environment '{EnvironmentName}'", exitCode, _environment.Name);
if (exitCode != 0)
{
var stderrText = stderrBuilder.ToString().Trim();
var errorMessage = string.IsNullOrEmpty(stderrText)
? $"rad deploy failed with exit code {exitCode}"
: $"rad deploy failed with exit code {exitCode}: {stderrText}";
logger.LogError("rad deploy failed for environment '{EnvironmentName}': {ErrorMessage}", _environment.Name, errorMessage);
context.ReportingStep.Log(LogLevel.Error, errorMessage);
throw new InvalidOperationException(errorMessage);
}
await deployTask.CompleteAsync(
$"Radius deployment complete for '{_environment.Name}'",
cancellationToken: cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (ex is not InvalidOperationException and not OperationCanceledException)
{
logger.LogError(ex, "Unexpected error during rad deploy for environment '{EnvironmentName}'", _environment.Name);
context.ReportingStep.Log(LogLevel.Error, ex.Message);
throw;
}
finally
{
DeleteDeployParametersFile(parametersFilePath, logger);
}
}
View on GitHub (pinned to 25830f84bd)