microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
362 stars 29 forks source link

Container Apps Environment in Workload Profiles type doesn't allow deploying container app on consumption profile with maximum CPU/Memory combo in Bicep #1075

Open jamesmcroft opened 7 months ago

jamesmcroft commented 7 months ago

Please provide us with the following information:

This issue is a: (mark with an x)

Issue description

A clear and concise description of the observed issue.

Using Bicep, it is not possible to deploy a Container App to a Container Apps Environment using the maximum CPU/Memory combination in the consumption profile (i.e. cpu: '4.0' memory: '8.0Gi') as defined in the documentation here: https://learn.microsoft.com/en-us/azure/container-apps/workload-profiles-overview#profile-types

This is supported in the portal and can be updated manually, but this will break with subsequent runs of the Bicep in CI/CD pipelines due to the limitation.

The error returned from Bicep is:

{"code":"ContainerAppInvalidResourceTotal","message":"The total requested CPU and memory resources for this application (CPU: 4.0, memory: 8.0) is invalid. Total CPU and memory for all containers defined in a Container App must add up to one of the following CPU - Memory combinations: [cpu: 0.25, memory: 0.5Gi]; [cpu: 0.5, memory: 1.0Gi]; [cpu: 0.75, memory: 1.5Gi]; [cpu: 1.0, memory: 2.0Gi]; [cpu: 1.25, memory: 2.5Gi]; [cpu: 1.5, memory: 3.0Gi]; [cpu: 1.75, memory: 3.5Gi]; [cpu: 2.0, memory: 4.0Gi]"}

Steps to reproduce

  1. Create a container app using the following Bicep:
resource containerApp 'Microsoft.App/containerApps@2023-05-01' = {
    name: <name>
    location: <location>
    tags: <tags>
    identity: {
        type: 'UserAssigned'
        userAssignedIdentities: {
            '<containerAppIdentityId>': {}
        }
    }
    properties: {
        environmentId: <containerAppsEnvironmentId>
        configuration: {
            registries: [
                {
                    server: '<containerRegistryName>.azurecr.io'
                    identity: <containerAppIdentityId>
                }
            ] 
            ingress: {
                  external: false
                  targetPort: 5000
                  transport: 'auto'
            }
        }
        template: {
            containers: [
                {
                    image: '<containerRegistryName>.azurecr.io/<containerImageName>'
                    name: name
                    resources: {
                        cpu: '4.0'
                        memory: '8.0Gi'
                    }
                }
            ]
            scale: {
                minReplicas: 1
                maxReplicas: 3
                rules: []
            }
        }
    }
}

Expected behavior [What you expected to happen.]

The container app should successfully deploy.

Actual behavior [What actually happened.]

The error returned from Bicep is:

{"code":"ContainerAppInvalidResourceTotal","message":"The total requested CPU and memory resources for this application (CPU: 4.0, memory: 8.0) is invalid. Total CPU and memory for all containers defined in a Container App must add up to one of the following CPU - Memory combinations: [cpu: 0.25, memory: 0.5Gi]; [cpu: 0.5, memory: 1.0Gi]; [cpu: 0.75, memory: 1.5Gi]; [cpu: 1.0, memory: 2.0Gi]; [cpu: 1.25, memory: 2.5Gi]; [cpu: 1.5, memory: 3.0Gi]; [cpu: 1.75, memory: 3.5Gi]; [cpu: 2.0, memory: 4.0Gi]"}

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

Ex. Did this issue occur in the CLI or the Portal?

Bicep

jamesmcroft commented 7 months ago

Exploring this further, I have discovered that it will only work if you provide the workloadProfileName in the Bicep.

If omitted, it appears that the backing processing is assuming it is deploying to a Consumption type Container Apps Environment. The expectation though is that it would be aware we are deploying to a workload profile type environment and deploy accordingly.