{"record":{"id":"2a0c76903f9b5886","repo":"microsoft/aspire","slug":"errormessage-rad-deploy-failed-with-exit-code-exitcode-or","errorCode":null,"errorMessage":"{errorMessage} (\"rad deploy failed with exit code {exitCode}\" or \"rad deploy failed with exit code {exitCode}: {stderrText}\")","messagePattern":"(.+?) \\(\"rad deploy failed with exit code (.+?)\" or \"rad deploy failed with exit code (.+?): (.+?)\"\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Radius/Publishing/RadiusDeploymentPipelineStep.cs","lineNumber":637,"sourceCode":"\n                throw;\n            }\n\n            var exitCode = process.ExitCode;\n\n            logger.LogInformation(\"rad deploy exited with code {ExitCode} for environment '{EnvironmentName}'\", exitCode, _environment.Name);\n\n            if (exitCode != 0)\n            {\n                var stderrText = stderrBuilder.ToString().Trim();\n                var errorMessage = string.IsNullOrEmpty(stderrText)\n                    ? $\"rad deploy failed with exit code {exitCode}\"\n                    : $\"rad deploy failed with exit code {exitCode}: {stderrText}\";\n\n                logger.LogError(\"rad deploy failed for environment '{EnvironmentName}': {ErrorMessage}\", _environment.Name, errorMessage);\n                context.ReportingStep.Log(LogLevel.Error, errorMessage);\n\n                throw new InvalidOperationException(errorMessage);\n            }\n\n            await deployTask.CompleteAsync(\n                $\"Radius deployment complete for '{_environment.Name}'\",\n                cancellationToken: cancellationToken).ConfigureAwait(false);\n        }\n        catch (Exception ex) when (ex is not InvalidOperationException and not OperationCanceledException)\n        {\n            logger.LogError(ex, \"Unexpected error during rad deploy for environment '{EnvironmentName}'\", _environment.Name);\n            context.ReportingStep.Log(LogLevel.Error, ex.Message);\n            throw;\n        }\n        finally\n        {\n            DeleteDeployParametersFile(parametersFilePath, logger);\n        }\n    }\n","sourceCodeStart":619,"sourceCodeEnd":655,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Radius/Publishing/RadiusDeploymentPipelineStep.cs#L619-L655","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n// rad deploy failed with exit code 1: recipe 'redis' not found in environment\n\n// after (shell)\nrad recipe list   # confirm available recipes, then align the resource's recipe name\nbuilder.AddRedis(\"cache\").WithRecipe(\"redis-recipe\");","handlingStrategy":"try-catch","validationCode":"// Pre-deploy sanity checks: environment reachable and Bicep exists\nvar bicepPath = Path.Combine(outputDir, \"app.bicep\");\nif (!File.Exists(bicepPath)) throw new InvalidOperationException(\"Run publish before deploy.\");\n// and confirm recipes referenced by the model exist:\n// rad recipe list --environment <env>","typeGuard":null,"tryCatchPattern":"try { await deployStep.ExecuteAsync(context, ct); }\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"rad deploy failed\"))\n{\n    // The stderr portion of the message holds rad's actual error — surface it\n    logger.LogError(ex, \"Radius deployment failed; see embedded stderr for root cause.\");\n}","preventionTips":["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"],"tags":["radius","deploy","cli","process-exit-code","bicep"],"backgroundTag":"http-error-response","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"}