Search code examples
azureazure-cliazure-container-apps

az cli : create container app via yaml fail due to parsing to json


I've the error below when trying to create a containerapp through yaml file.

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"})

the content of 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

I had activate verbose mode in the above command, I had many python exceptions. TypeError: Object of type HTTPError is not JSON serializable

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.

Solution

  • I found it. There was another boolean in the Ingress allowInsecure not specified in the yaml file. I added it, and now it works as expected:

      configuration:
        ingress:
          external: true
          allowInsecure: false
          targetPort: 80