microsoft/aspire · error · InvalidOperationException
ASPIRERADIUS059
ASPIRERADIUS059
Error message
Could not resolve the active Radius workspace kube-context from '{attemptedConfigPath}'. Configure the active rad workspace, or set {KubeContextOverrideEnvironmentVariable} to the kubectl context that targets the same cluster before re-running deploy. Diagnostic: ASPIRERADIUS059. What it means
The step needs the kubectl context of the active Radius workspace to target the right cluster for SealedSecret operations. It parses the rad config at attemptedConfigPath; if no active workspace context (or it is blank) is found, ASPIRERADIUS059 is thrown, pointing to `rad workspace` configuration or the KubeContextOverrideEnvironmentVariable override.
Solutions
- Set the override env var (see KubeContextOverrideEnvironmentVariable in the message) to the kubectl context that targets the same cluster, then re-run deploy.
- Configure the active workspace: `rad workspace switch <workspace>` (and `rad init` if none exists) so the rad config has a kube-context.
- Inspect the rad config file named in the error and confirm the active workspace entry has a non-empty context.
Example fix
// before rad deploy app.bicep # no active rad workspace context // after export ASPIRE_RADIUS_KUBE_CONTEXT_OVERRIDE=my-cluster-context # or: rad workspace switch my-workspace rad deploy app.bicep
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: resolve the kube context the same way the step does
var radConfig = File.ReadAllText(radConfigPath);
if (!radConfig.Contains("kubeContext") || string.IsNullOrWhiteSpace(ExtractContext(radConfig)))
Environment.SetEnvironmentVariable("ASPIRE_RADIUS_KUBE_CONTEXT_OVERRIDE", "my-cluster-context"); Prevention
- Run `rad workspace switch` (or `rad init`) on every machine/CI runner before deploying.
- Set the kube-context override env var explicitly in pipelines that target a known cluster.
- Keep the rad config and kubeconfig consistent — the override context must target the same cluster as the rad workspace.
When it happens
Trigger: RequireKubeContext (invoked while resolving kubeContext) finds parsedContext null/whitespace after reading the rad config file — no active rad workspace is configured, or the workspace entry lacks a kube-context, and no override env var is set.
Common situations: Fresh machine or CI runner where `rad workspace switch` was never run; multiple rad workspaces with none active; rad config at a non-default path passed explicitly but pointing at a workspace without a context; deployment to a cluster different from the rad default requiring an explicit override.
Understand the failure class
Background: "missing required config value" errors: why libraries refuse to start when a configuration key is empty, unset, or blank — this error's family across 48 libraries.
Related errors
- A recipe parameter on Radius environment
- A recipe parameter on Radius environment
- ASPIRERADIUS010
- ASPIRERADIUS065
- Bicep file not found at
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/14805b27e6afe135.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Radius/Publishing/SealedSecretApplyStep.cs:690
// shared resolver so this step and the control plane version gate can never disagree about
// which cluster is being inspected. Kept as a forwarder because the parsing behavior is
// exercised directly by SealedSecretApplyStepTests.
internal static string? ParseActiveWorkspaceContext(string text) =>
RadiusWorkspaceKubeContext.ParseActiveWorkspaceContext(text);
internal static string RequireKubeContext(string? overrideContext, string? parsedContext, string attemptedConfigPath)
{
if (!string.IsNullOrWhiteSpace(overrideContext))
{
return overrideContext.Trim();
}
if (!string.IsNullOrWhiteSpace(parsedContext))
{
return parsedContext.Trim();
}
throw new InvalidOperationException(
$"Could not resolve the active Radius workspace kube-context from '{attemptedConfigPath}'. Configure " +
$"the active rad workspace, or set {KubeContextOverrideEnvironmentVariable} to the kubectl context " +
"that targets the same cluster before re-running deploy. Diagnostic: ASPIRERADIUS059.");
}
private static async Task<bool> DetectKubectlAsync(CancellationToken cancellationToken)
{
try
{
using var process = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "kubectl",
ArgumentList = { "version", "--client" },
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,View on GitHub (pinned to 25830f84bd)