diff --git a/.azure/applications/graphql/main.bicep b/.azure/applications/graphql/main.bicep index 2a3765386..afb8b86cf 100644 --- a/.azure/applications/graphql/main.bicep +++ b/.azure/applications/graphql/main.bicep @@ -1,5 +1,7 @@ targetScope = 'resourceGroup' +import { Scale } from '../../modules/containerApp/main.bicep' + @description('The tag of the image to be used') @minLength(3) param imageTag string @@ -106,15 +108,16 @@ var probes = [ } ] -var scale = { +@description('The scaling configuration for the container app') +param scale Scale = { minReplicas: 2 maxReplicas: 10 rules: [ { custom: { type: 'cpu' - metricType: 'Utilization' metadata: { + type: 'Utilization' value: '70' } } @@ -122,8 +125,8 @@ var scale = { { custom: { type: 'memory' - metricType: 'Utilization' metadata: { + type: 'Utilization' value: '70' } } diff --git a/.azure/applications/web-api-eu/main.bicep b/.azure/applications/web-api-eu/main.bicep index 45c9181e0..fa86c529a 100644 --- a/.azure/applications/web-api-eu/main.bicep +++ b/.azure/applications/web-api-eu/main.bicep @@ -1,5 +1,7 @@ targetScope = 'resourceGroup' +import { Scale } from '../../modules/containerApp/main.bicep' + @description('The tag of the image to be used') @minLength(3) param imageTag string @@ -77,15 +79,16 @@ var containerAppEnvVars = [ } ] -var scale = { +@description('The scaling configuration for the container app') +param scale Scale = { minReplicas: 2 maxReplicas: 10 rules: [ { custom: { type: 'cpu' - metricType: 'Utilization' metadata: { + type: 'Utilization' value: '70' } } @@ -93,14 +96,15 @@ var scale = { { custom: { type: 'memory' - metricType: 'Utilization' metadata: { + type: 'Utilization' value: '70' } } } ] } + resource environmentKeyVaultResource 'Microsoft.KeyVault/vaults@2023-07-01' existing = { name: environmentKeyVaultName } diff --git a/.azure/modules/containerApp/main.bicep b/.azure/modules/containerApp/main.bicep index 68bc34168..de6d9e1cd 100644 --- a/.azure/modules/containerApp/main.bicep +++ b/.azure/modules/containerApp/main.bicep @@ -31,10 +31,30 @@ param revisionSuffix string @description('The probes for the container app') param probes array = [] +@export() +type ScaleRule = { + // add additional types as needed: https://keda.sh/docs/2.15/scalers/ + custom: { + type: 'cpu' | 'memory' + metadata: { + type: 'Utilization' + value: string + } + } +} + +@export() +type Scale = { + minReplicas: int + maxReplicas: int + rules: ScaleRule[] +} + @description('The scaling configuration for the container app') -param scale object = { +param scale Scale = { minReplicas: 1 - maxReplicas: 1 // temp disable scaling by default for outbox scheduling + maxReplicas: 1 + rules: [] } // TODO: Refactor to make userAssignedIdentityId a required parameter once all container apps use user-assigned identities