`az aks command` does not always honor `--output` parameter
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
### 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:
```console
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**:
```console
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"):
```console
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:
```console
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
```console
az version
{
"azure-cli": "2.70.0",
"azure-cli-core": "2.70.0",
"azure-cli-telemetry": "1.1.0",
"extensions": {}
}
```
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.