You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

通过YAML创建Azure Container App时遇JSON解析失败问题

问题:通过YAML创建Azure容器应用时遇到布尔值转换错误

错误执行命令及输出

kallel [ ~ ]$ az containerapp create -n my-containerapp --environment fk-apps-env-module -g fkallel-sbx2   --yaml "hello.yaml"
Additional flags were passed along with --yaml. These flags will be ignored, and the configuration defined in the yaml will be used instead
Bad Request({"type":"https://tools.ietf.org/html/rfc9110#section-15.5.1","title":"One or more validation errors occurred.","status":400,"errors":{"$":["The JSON value could not be converted to System.Boolean. Path: $ | LineNumber: 0 | BytePositionInLine: 4."]},"traceId":"00-b6560ac8c2d75ca90655be0591a4712a-b9180e8e23de9eb7-01"})

涉及的YAML配置文件(hello.yaml)

identity:
  type: SystemAssigned
properties:
  environmentId: "/subscriptions/my-subscription/resourceGroups/fkallel-sbx2/providers/Microsoft.App/managedEnvironments/fk-apps-env-module"
  workloadProfileName: Consumption
  configuration:
    ingress:
      external: true
      targetPort: 80
      customDomains:
      - name: demo.exple.fr
        bindingType: SniEnabled
        certificateId: "/subscriptions/my-subscription/resourceGroups/fkallel-sbx2/providers/Microsoft.App/managedEnvironments/fk-apps-env-module/certificates/ssl-cert-qua"
      traffic:
      - weight: 100
        latest_revision: true
      clientCertificateMode: accept
    maxInactiveRevisions: 10
  template:
    containers:
    - image: docker.io/nginx:latest
      name: nginx2
      probes:
      - type: Liveness
        httpGet:
          path: "/"
          port: 80
        initialDelaySeconds: 3
        periodSeconds: 3
    scale:
      minReplicas: 1
      maxReplicas: 2

Verbose模式下的额外异常

TypeError: Object of type HTTPError is not JSON serializable

Azure CLI版本信息

kallel [ ~ ]$ az --version
azure-cli                         2.63.0
core                              2.63.0
telemetry                          1.1.0
Extensions:
ai-examples                        0.2.5
ml                                2.29.0
ssh                                2.0.5
Dependencies:
msal                              1.30.0
azure-mgmt-resource               23.1.1
Python location '/usr/bin/python3.9'
Extensions directory '/home/kallel/.azure/cliextensions'
Extensions system directory '/usr/lib/python3.9/site-packages/azure-cli-extensions'

Python (Linux) 3.9.19 (main, Jul 31 2024, 03:47:41) 
[GCC 11.2.0]

Legal docs and information: aka.ms/AzureCliLegal


Your CLI is up-to-date.

问题原因及解决方法

问题出在YAML配置的traffic节点下的latest_revision字段——Azure容器应用的API要求该字段使用驼峰命名latestRevision,而非下划线分隔格式。YAML转JSON后,下划线格式的字段无法被后端正确识别为布尔值类型,从而触发转换错误。

修改YAML中的对应字段:
将

latest_revision: true

改为

latestRevision: true

修改后重新执行az containerapp create命令即可解决该错误。

内容的提问来源于stack exchange,提问作者user3620514

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 22:41:17