microsoft/aspire · error
az resource list failed
Error message
az resource list failed (exit code {result.ExitCode}): {result.StandardError} What it means
To locate the resource group of an AKS cluster, the pipeline runs `az resource list` (via BuildResourceGroupQueryArguments) scoped to the subscription and cluster name. A non-zero exit code from the az CLI means the query itself failed - it did not just return no clusters - so Aspire surfaces the exit code and stderr verbatim.
Solutions
- Run `az login` (or configure a service principal / managed identity) and confirm `az account show` points at the expected subscription.
- Run the same `az resource list` query manually with the printed arguments to see the full error.
- Verify network/proxy access to management.azure.com from the machine running the pipeline.
- Update the az CLI (`az upgrade`) and extensions if stderr indicates extension or schema errors.
Example fix
// before az resource list --query "[...]" // fails: not logged in // after az login az account set --subscription 00000000-0000-0000-0000-000000000000 // then rerun aspire deploy/destroy
Defensive patterns
Strategy: retry
Validate before calling
var check = Process.Start("az", "account show");
check.WaitForExit();
if (check.ExitCode != 0) throw new InvalidOperationException("az is not authenticated; run az login."); Try / catch
try { await DeployAsync(); }
catch (InvalidOperationException ex) when (ex.Message.Contains("az resource list failed"))
{
// inspect exit code/stderr, re-authenticate with az login, then retry
} Prevention
- Authenticate az before pipeline runs (az login or service principal)
- Verify subscription access with az account show
- Check proxy/firewall access to management.azure.com in CI
When it happens
Trigger: GetResourceGroupAsync invoked (via the resourceGroup property) when the `az` process exits non-zero: az CLI not authenticated, subscription not set/accessible, invalid arguments, network failure reaching Azure ARM endpoints, or az CLI version/extension errors.
Common situations: az not logged in (`az login` never run or token expired); the subscription was deleted or the principal lacks Reader on it; corporate proxy blocking ARM; using `az` from CI without a service principal configured.
Related errors
- az aks get-credentials failed
- az resource list failed while checking AKS cluster existence
- Azure destroy step for environment
- Azure environment resource required by AKS environment
- AzureKubernetesLoadBalancerResource
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/b4805409827684a1.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.Kubernetes/AzureKubernetesEnvironmentResource.AksPipeline.cs:909
{
if (!string.IsNullOrEmpty(savedResourceGroup))
{
return savedResourceGroup;
}
// Keep the query scoped to the resolved subscription rather than the CLI default, otherwise
// a same-named cluster in the ambient subscription could be picked up instead.
logger.LogDebug(
"Resource group not in deployment state, querying Azure for cluster '{ClusterName}'",
clusterName);
var result = await runAzCommandAsync(
azPath,
BuildResourceGroupQueryArguments(subscriptionId, clusterName)).ConfigureAwait(false);
if (result.ExitCode != 0)
{
throw new InvalidOperationException(
$"az resource list failed (exit code {result.ExitCode}): {result.StandardError}");
}
// With '-o tsv' the query emits one resource group per matching cluster, newline separated:
// my-rg
// other-rg
// A cluster name is only unique within a resource group, not within a subscription, so the
// query can legitimately return several rows. Picking one would silently deploy into, and
// hand back credentials for, an unrelated cluster.
var resourceGroups = result.StandardOutput
.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
if (resourceGroups.Length == 0)
{
throw new InvalidOperationException(
$"Could not resolve resource group for AKS cluster '{clusterName}'. " +
"Ensure Azure provisioning has completed.");
}View on GitHub (pinned to 25830f84bd)