From 68273d967a105e48d51b3284b42d71aa8172f02f Mon Sep 17 00:00:00 2001 From: Magnus Sandgren <5285192+MagnusSandgren@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:09:49 +0200 Subject: [PATCH 1/2] Add scale to service and webapi so --- .azure/applications/service/main.bicep | 29 +++++++++++++++++++++++ .azure/applications/web-api-so/main.bicep | 29 +++++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/.azure/applications/service/main.bicep b/.azure/applications/service/main.bicep index ed2f3c6fc..52a661bf1 100644 --- a/.azure/applications/service/main.bicep +++ b/.azure/applications/service/main.bicep @@ -40,6 +40,34 @@ param appConfigurationName string @minLength(3) param environmentKeyVaultName string +@description('The scaling configuration for the container app') +param scale Scale = { + minReplicas: 2 + maxReplicas: 10 + rules: [ + { + name: 'cpu' + custom: { + type: 'cpu' + metadata: { + type: 'Utilization' + value: '70' + } + } + } + { + name: 'memory' + custom: { + type: 'memory' + metadata: { + type: 'Utilization' + value: '70' + } + } + } + ] +} + var namePrefix = 'dp-be-${environment}' var baseImageUrl = 'ghcr.io/digdir/dialogporten-' var tags = { @@ -166,6 +194,7 @@ module containerApp '../../modules/containerApp/main.bicep' = { port: port revisionSuffix: revisionSuffix userAssignedIdentityId: managedIdentity.id + scale: scale // TODO: Once all container apps use user-assigned identities, remove this comment and ensure userAssignedIdentityId is always provided } dependsOn: [ diff --git a/.azure/applications/web-api-so/main.bicep b/.azure/applications/web-api-so/main.bicep index d557c37ed..b008c8762 100644 --- a/.azure/applications/web-api-so/main.bicep +++ b/.azure/applications/web-api-so/main.bicep @@ -43,6 +43,34 @@ param appConfigurationName string @secure() param environmentKeyVaultName string +@description('The scaling configuration for the container app') +param scale Scale = { + minReplicas: 2 + maxReplicas: 10 + rules: [ + { + name: 'cpu' + custom: { + type: 'cpu' + metadata: { + type: 'Utilization' + value: '70' + } + } + } + { + name: 'memory' + custom: { + type: 'memory' + metadata: { + type: 'Utilization' + value: '70' + } + } + } + ] +} + var namePrefix = 'dp-be-${environment}' var baseImageUrl = 'ghcr.io/digdir/dialogporten-' var tags = { @@ -129,6 +157,7 @@ module containerApp '../../modules/containerApp/main.bicep' = { probes: probes port: port revisionSuffix: revisionSuffix + scale: scale } } From 5ea4ed53bba846340b59b40247c05a6103e30464 Mon Sep 17 00:00:00 2001 From: Magnus Sandgren <5285192+MagnusSandgren@users.noreply.github.com> Date: Fri, 18 Oct 2024 10:14:03 +0200 Subject: [PATCH 2/2] Import scale type --- .azure/applications/service/main.bicep | 2 ++ .azure/applications/web-api-so/main.bicep | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.azure/applications/service/main.bicep b/.azure/applications/service/main.bicep index 52a661bf1..26812e1a8 100644 --- a/.azure/applications/service/main.bicep +++ b/.azure/applications/service/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 diff --git a/.azure/applications/web-api-so/main.bicep b/.azure/applications/web-api-so/main.bicep index b008c8762..d9085b77d 100644 --- a/.azure/applications/web-api-so/main.bicep +++ b/.azure/applications/web-api-so/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