Skip to content

Unable to create configmap with json data using az aks command invoke #31795

@RichardChen820

Description

@RichardChen820

Describe the bug

I need to use the az aks command invoke to create a configMap with json data. But can't get the expected result.

Related command

az aks command invoke

Errors

Use this command to create a configmap with json data.

az aks command invoke -g myrg -n mycluster --command "kubectl create configmap democm --from-literal='demojson={`"foo`":`"bar`"}'"

Turns out the output is not a valid json, lost the double quotes

apiVersion: v1
data:
  demojson: '{foo:bar}'
kind: ConfigMap

If I use the kubectl directly, the result is expected:

kubectl create configmap democm --from-literal='demojson={"test":"test"}'
apiVersion: v1
data:
  demojson: '{"test":"test"}'
kind: ConfigMap

Issue script & Debug output

N/A

Expected behavior

The configmap generated should have valid JSON data, not missing the double quotes.

Environment Summary

azure-cli 2.74.0 *

core 2.74.0 *
telemetry 1.1.0

Extensions:
aks-preview 18.0.0b13
dev-spaces 1.0.6
k8s-extension 1.6.5
ml 2.32.4

Dependencies:
msal 1.32.3
azure-mgmt-resource 23.3.0

Python location 'C:\Program Files\Microsoft SDKs\Azure\CLI2\python.exe'
Config directory 'C:\Users\junbchen.azure'
Extensions directory 'C:\Users\junbchen.azure\cliextensions'

Python (Windows) 3.12.10 (tags/v3.12.10:0cc8128, Apr 8 2025, 12:21:36) [MSC v.1943 64 bit (AMD64)]

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    AKSaz aks/acs/openshiftAuto-AssignAuto assign by botAuto-ResolveAuto resolve by botService AttentionThis issue is responsible by Azure service team.bugThis issue requires a change to an existing behavior in the product in order to be resolved.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions