Azure / bicep-types-az

Bicep type definitions for ARM resources
MIT License
86 stars 27 forks source link

ContainerApps: cpu 0.5 not valid #1404

Open cveld opened 1 year ago

cveld commented 1 year ago

Resource Type

Microsoft.App/containerApps

Api Version

2022-03-01

Issue Type

Inaccurate property type(s)

Other Notes

The type is marked as integer whereas the value of 0.5 is accepted by Azure. In Visual Studio Code I therefore get a yellow squiggly line.

Bicep Repro

param containerappName string = 'mycontainerapp3'
param location string = 'westeurope'
param environment_name string = 'my-environment'
param container_image string = 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest'

@secure()
param registry_password string = newGuid()

resource containerapp 'Microsoft.App/containerApps@2022-03-01' = {
  name: containerappName
  location: location
  identity: {
    type: 'None'
  }
  properties: {
    managedEnvironmentId: resourceId('Microsoft.App/managedEnvironments', environment_name)
    configuration: {
      secrets: [
        {
          name: 'mysecret'
          value: 'thisismysecret'
        }
        {
          name: 'myregistrypassword'
          value: registry_password
        }
      ]
      ingress: {
        external: true
        targetPort: 80
        allowInsecure: false
        traffic: [
          {
            latestRevision: true
            weight: 100
          }
        ]
      }
      registries: [
        {
          server: 'myregistry.azurecr.io'
          username: containerappName
          passwordSecretRef: 'myregistrypassword'
        }
      ]
      // dapr: {
      //   appId: containerappName
      //   appPort: 80
      //   appProtocol: 'http'
      //   enabled: true
      // }
    }
    template: {
      revisionSuffix: 'myrevision'
      containers: [
        {
          name: 'main'
          image: container_image
          env: [
            {
              name: 'HTTP_PORT'
              value: '80'
            }
            {
              name: 'SECRET_VAL'
              secretRef: 'mysecret'
            }
          ]
          command: [
            'npm'
            'start'
          ]
          resources: {
            cpu: '0.5'
            memory: '1Gi'
          }
          probes: []
          // probes: [
          //   {
          //     type: 'liveness'
          //     httpGet: {
          //       path: '/health'
          //       port: 8080
          //       httpHeaders: [
          //         {
          //           name: 'Custom-Header'
          //           value: 'liveness probe'
          //         }
          //       ]
          //     }
          //     initialDelaySeconds: 7
          //     periodSeconds: 3
          //   }
          //   {
          //     type: 'readiness'
          //     tcpSocket: {
          //       port: 8081
          //     }
          //     initialDelaySeconds: 10
          //     periodSeconds: 3
          //   }
          //   {
          //     type: 'startup'
          //     httpGet: {
          //       path: '/startup'
          //       port: 8080
          //       httpHeaders: [
          //         {
          //           name: 'Custom-Header'
          //           value: 'startup probe'
          //         }
          //       ]
          //     }
          //     initialDelaySeconds: 3
          //     periodSeconds: 3
          //   }
          // ]
          volumeMounts: [
            {
              mountPath: '/myempty'
              volumeName: 'myempty'
            }
            {
              mountPath: '/myfiles'
              volumeName: 'azure-files-volume'
            }
          ]
        }
      ]
      scale: {
        minReplicas: 1
        maxReplicas: 3
      }
      volumes: [
        {
          name: 'myempty'
          storageType: 'EmptyDir'
        }
        {
          name: 'azure-files-volume'
          storageType: 'AzureFile'
          storageName: 'mystorage'
        }
      ]
    }
  }
}

Confirm

GeekTrainer commented 1 year ago

Having the same issue on 2022-10-01

ghost commented 1 year ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @calvinsID. Please see https://aka.ms/biceptypesinfo for troubleshooting help.

Issue Details
### Resource Type Microsoft.App/containerApps ### Api Version 2022-03-01 ### Issue Type Inaccurate property type(s) ### Other Notes The type is marked as integer whereas the value of 0.5 is accepted by Azure. In Visual Studio Code I therefore get a yellow squiggly line. ### Bicep Repro ```bicep param containerappName string = 'mycontainerapp3' param location string = 'westeurope' param environment_name string = 'my-environment' param container_image string = 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' @secure() param registry_password string = newGuid() resource containerapp 'Microsoft.App/containerApps@2022-03-01' = { name: containerappName location: location identity: { type: 'None' } properties: { managedEnvironmentId: resourceId('Microsoft.App/managedEnvironments', environment_name) configuration: { secrets: [ { name: 'mysecret' value: 'thisismysecret' } { name: 'myregistrypassword' value: registry_password } ] ingress: { external: true targetPort: 80 allowInsecure: false traffic: [ { latestRevision: true weight: 100 } ] } registries: [ { server: 'myregistry.azurecr.io' username: containerappName passwordSecretRef: 'myregistrypassword' } ] // dapr: { // appId: containerappName // appPort: 80 // appProtocol: 'http' // enabled: true // } } template: { revisionSuffix: 'myrevision' containers: [ { name: 'main' image: container_image env: [ { name: 'HTTP_PORT' value: '80' } { name: 'SECRET_VAL' secretRef: 'mysecret' } ] command: [ 'npm' 'start' ] resources: { cpu: '0.5' memory: '1Gi' } probes: [] // probes: [ // { // type: 'liveness' // httpGet: { // path: '/health' // port: 8080 // httpHeaders: [ // { // name: 'Custom-Header' // value: 'liveness probe' // } // ] // } // initialDelaySeconds: 7 // periodSeconds: 3 // } // { // type: 'readiness' // tcpSocket: { // port: 8081 // } // initialDelaySeconds: 10 // periodSeconds: 3 // } // { // type: 'startup' // httpGet: { // path: '/startup' // port: 8080 // httpHeaders: [ // { // name: 'Custom-Header' // value: 'startup probe' // } // ] // } // initialDelaySeconds: 3 // periodSeconds: 3 // } // ] volumeMounts: [ { mountPath: '/myempty' volumeName: 'myempty' } { mountPath: '/myfiles' volumeName: 'azure-files-volume' } ] } ] scale: { minReplicas: 1 maxReplicas: 3 } volumes: [ { name: 'myempty' storageType: 'EmptyDir' } { name: 'azure-files-volume' storageType: 'AzureFile' storageName: 'mystorage' } ] } } } ``` ### Confirm - [X] I have searched this repository and have not found similar issue reports.
Author: cveld
Assignees: -
Labels: `inaccuracy`, `RP: Microsoft.App`, `Service Attention`, `ContainerApp`
Milestone: -
ckittel commented 1 year ago

Same still on 2022-11-01-preview.

acarter24 commented 1 year ago

Same issue on 2023-05-01, using any for now

gcarrarom commented 1 year ago

Any updates?

carlin-q-scott commented 8 months ago

You can disable the type checking for the cpu limit using a linter comment:

#disable-next-line BCP036
cpu: '0.5'

Bicep linter directives are documented here. Amazingly, VS Code Intellisense knew which code to use after the linter directive to silence the type checking. Copilot did not.