Skip to content

az aks command does not always honor --output parameter #31157

@l3ender

Description

@l3ender

Describe the bug

If I am using az aks command invoke and the related az aks command result, using --output json does not always return JSON content.

Related command

az aks command

Errors

Command output is not in JSON.

Issue script & Debug output

For example, I have a job which I want to wait for completion. I am using the following command:

az aks command invoke --resource-group my-rg --name my-cluster --command 'kubectl wait --for=condition=complete --timeout=10m -n my-namespace jobs/my-job' --no-wait --output json

This returns the following output in non-json:

command id: 70f2846682cf4cd38aa36857d4274570, started at: None, status: Running
Please use command "az aks command result -g my-rg -n my-cluster -i 70f2846682cf4cd38aa36857d4274570" to get the future execution result

Then if I check on the status of the command, I see the same issue (note the status is still "running"):

az aks command result --resource-group my-rg --name my-cluster --command-id 70f2846682cf4cd38aa36857d4274570 --output json
command id: 70f2846682cf4cd38aa36857d4274570, started at: 2025-03-30T02:28:31Z, status: Running
Please use command "az aks command result -g my-rg -n my-cluster -i 70f2846682cf4cd38aa36857d4274570" to get the future execution result

However, once the job finishes, the command does return JSON as expected:

az aks command result --resource-group my-rg --name my-cluster --command-id 70f2846682cf4cd38aa36857d4274570 --output json
{
  "exitCode": 0,
  "finishedAt": "2025-03-30T02:31:34+00:00",
  "id": "70f2846682cf4cd38aa36857d4274570",
  "logs": "job.batch/my-job condition met\n",
  "provisioningState": "Succeeded",
  "reason": null,
  "startedAt": "2025-03-30T02:28:31+00:00"
}

Expected behavior

Our expectation is that the command should always return JSON if specified as a parameter.

Environment Summary

az version
{
  "azure-cli": "2.70.0",
  "azure-cli-core": "2.70.0",
  "azure-cli-telemetry": "1.1.0",
  "extensions": {}
}

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    AKSaz aks/acs/openshiftAuto-AssignAuto assign by botService AttentionThis issue is responsible by Azure service team.act-observability-squadbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions