diff --git a/infrastructure/templates/public-api/application/public-api/publicApiApp.bicep b/infrastructure/templates/public-api/application/public-api/publicApiApp.bicep index 04edeef331..65ccbedada 100644 --- a/infrastructure/templates/public-api/application/public-api/publicApiApp.bicep +++ b/infrastructure/templates/public-api/application/public-api/publicApiApp.bicep @@ -152,6 +152,8 @@ module apiContainerAppModule '../../components/containerApp.bicep' = { memorySizeGis: resourceAndScalingConfig.memoryGis minReplicas: resourceAndScalingConfig.minReplicas maxReplicas: resourceAndScalingConfig.maxReplicas + scaleAtConcurrentHttpRequests: resourceAndScalingConfig.scaleAtConcurrentHttpRequests + workloadProfileName: resourceAndScalingConfig.workloadProfileName tagValues: tagValues } } diff --git a/infrastructure/templates/public-api/ci/azure-pipelines.yml b/infrastructure/templates/public-api/ci/azure-pipelines.yml index 5412ea9816..a90d6cc9c5 100644 --- a/infrastructure/templates/public-api/ci/azure-pipelines.yml +++ b/infrastructure/templates/public-api/ci/azure-pipelines.yml @@ -13,6 +13,9 @@ parameters: - name: deployDataProcessor displayName: Does the Data Processor need creating or updating? default: true + - name: deployDocsSite + displayName: Does the Public API static docs site need creating or updating? + default: true - name: deployAlerts displayName: Whether to create or update Azure Monitor alerts during this deploy. default: false @@ -58,6 +61,8 @@ variables: value: ${{ parameters.deployContainerApp }} - name: deployDataProcessor value: ${{ parameters.deployDataProcessor }} + - name: deployDocsSite + value: ${{ parameters.deployDocsSite }} - name: deployAlerts value: ${{ parameters.deployAlerts }} - name: awaitActiveOrchestrations diff --git a/infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml b/infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml index a7e17c543f..1fe51fc720 100644 --- a/infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml +++ b/infrastructure/templates/public-api/ci/jobs/deploy-api-docs.yml @@ -10,6 +10,7 @@ parameters: jobs: - deployment: DeployPublicApiDocs displayName: Deploy Public API docs + condition: and(succeeded(), eq(variables.deployDocsSite, true)) dependsOn: ${{ parameters.dependsOn }} environment: ${{ parameters.environment }} strategy: diff --git a/infrastructure/templates/public-api/ci/jobs/deploy-infrastructure.yml b/infrastructure/templates/public-api/ci/jobs/deploy-infrastructure.yml index af0c39481d..056be35954 100644 --- a/infrastructure/templates/public-api/ci/jobs/deploy-infrastructure.yml +++ b/infrastructure/templates/public-api/ci/jobs/deploy-infrastructure.yml @@ -39,6 +39,7 @@ jobs: deployPsqlFlexibleServer: false deployContainerApp: false deployDataProcessor: false + deployDocsSite: false deployAlerts: false dataProcessorExists: false @@ -68,6 +69,7 @@ jobs: deployPsqlFlexibleServer: $(deployPsqlFlexibleServer) deployContainerApp: $(deployContainerApp) deployDataProcessor: $(deployDataProcessor) + deployDocsSite: $(deployDocsSite) deployAlerts: $(deployAlerts) dataProcessorExists: $(dataProcessorExists) diff --git a/infrastructure/templates/public-api/ci/tasks/deploy-bicep.yml b/infrastructure/templates/public-api/ci/tasks/deploy-bicep.yml index 2e9d5ca351..39a0196c10 100644 --- a/infrastructure/templates/public-api/ci/tasks/deploy-bicep.yml +++ b/infrastructure/templates/public-api/ci/tasks/deploy-bicep.yml @@ -20,6 +20,8 @@ parameters: default: true - name: deployDataProcessor type: string + - name: deployDocsSite + type: string - name: deployAlerts type: string - name: dataProcessorExists @@ -55,6 +57,7 @@ steps: deployPsqlFlexibleServer=${{ parameters.deployPsqlFlexibleServer }} \ deployContainerApp=${{ parameters.deployContainerApp }} \ deployDataProcessor=${{ parameters.deployDataProcessor }} \ + deployDocsSite=${{ parameters.deployDocsSite }} \ deployAlerts=${{ parameters.deployAlerts }} \ dataProcessorFunctionAppExists=${{ parameters.dataProcessorExists }} \ dataProcessorAppRegistrationClientId='$(dataProcessorAppRegistrationClientId)' \ diff --git a/infrastructure/templates/public-api/components/containerApp.bicep b/infrastructure/templates/public-api/components/containerApp.bicep index 24ad3fe156..e0fde3fad8 100644 --- a/infrastructure/templates/public-api/components/containerApp.bicep +++ b/infrastructure/templates/public-api/components/containerApp.bicep @@ -29,37 +29,28 @@ param corsPolicy { param workloadProfileName string = 'Consumption' @description('Number of CPU cores the container can use. Can be with a maximum of two decimals.') -@allowed([ - 1 - 2 - 3 - 4 -]) +@minValue(1) +@maxValue(8) param cpuCores int = 4 -@description('Amount of memory (in gibibytes, GiB) allocated to the container up to 4GiB. Can be with a maximum of two decimals. Ratio with CPU cores must be equal to 2.') -@allowed([ - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 -]) +@description('Amount of memory (in gibibytes, GiB) allocated to the container up to 32GiB. Can be with a maximum of two decimals. Ratio with CPU cores must be equal to 2.') +@minValue(1) +@maxValue(32) param memorySizeGis int = 8 @description('Minimum number of replicas that will be deployed') @minValue(0) -@maxValue(25) param minReplicas int = 1 @description('Maximum number of replicas that will be deployed') @minValue(0) -@maxValue(25) +@maxValue(1000) param maxReplicas int = 3 +@description('Number of concurrent requests required in order to trigger scaling out.') +@minValue(1) +param scaleAtConcurrentHttpRequests int? + @description('Specifies the database connection string') param appSettings { name: string @@ -172,16 +163,16 @@ resource containerApp 'Microsoft.App/containerApps@2024-03-01' = { scale: { minReplicas: minReplicas maxReplicas: maxReplicas - rules: [ + rules: union(scaleAtConcurrentHttpRequests != null ? [ { name: 'http-requests' http: { metadata: { - concurrentRequests: '10' + concurrentRequests: string(scaleAtConcurrentHttpRequests) } } } - ] + ] : [], []) } volumes: volumes } diff --git a/infrastructure/templates/public-api/main.bicep b/infrastructure/templates/public-api/main.bicep index 188456f9e8..4fe68b7a64 100644 --- a/infrastructure/templates/public-api/main.bicep +++ b/infrastructure/templates/public-api/main.bicep @@ -78,6 +78,9 @@ param deployContainerApp bool = true @description('Does the Data Processor need creating or updating?') param deployDataProcessor bool = true +@description('Does the Public API static docs site need creating or updating?') +param deployDocsSite bool = true + param deployAlerts bool = false @description('Public URLs of other components in the service.') @@ -116,6 +119,7 @@ param publicApiContainerAppConfig ContainerAppResourceConfig = { memoryGis: 8 minReplicas: 0 maxReplicas: 3 + scaleAtConcurrentHttpRequests: 10 workloadProfileName: 'Consumption' } @@ -309,7 +313,7 @@ module apiAppModule 'application/public-api/publicApiApp.bicep' = if (deployCont } // Deploy Public API docs. -module docsModule 'application/public-api/publicApiDocs.bicep' = { +module docsModule 'application/public-api/publicApiDocs.bicep' = if (deployDocsSite) { name: 'publicApiDocsModuleDeploy' params: { appSku: docsAppSku @@ -321,7 +325,7 @@ module docsModule 'application/public-api/publicApiDocs.bicep' = { var docsRewriteSetName = '${publicApiResourcePrefix}-docs-rewrites' // Create an Application Gateway to serve public traffic for the Public API Container App. -module appGatewayModule 'application/shared/appGateway.bicep' = if (deployContainerApp) { +module appGatewayModule 'application/shared/appGateway.bicep' = if (deployContainerApp && deployDocsSite) { name: 'appGatewayModuleDeploy' params: { location: location diff --git a/infrastructure/templates/public-api/parameters/main-dev.bicepparam b/infrastructure/templates/public-api/parameters/main-dev.bicepparam index d9b2425967..38b8767705 100644 --- a/infrastructure/templates/public-api/parameters/main-dev.bicepparam +++ b/infrastructure/templates/public-api/parameters/main-dev.bicepparam @@ -18,8 +18,16 @@ param publicApiContainerAppConfig = { cpuCores: 4 memoryGis: 8 minReplicas: 1 - maxReplicas: 16 + maxReplicas: 100 + scaleAtConcurrentHttpRequests: 5 workloadProfileName: 'Consumption' } +param publicApiContainerAppWorkloadProfiles = [{ + name: 'D8' + workloadProfileType: 'D8' + minimumCount: 0 + maximumCount: 10 +}] + param enableThemeDeletion = true diff --git a/infrastructure/templates/public-api/types.bicep b/infrastructure/templates/public-api/types.bicep index 44ea8544cf..76ab209845 100644 --- a/infrastructure/templates/public-api/types.bicep +++ b/infrastructure/templates/public-api/types.bicep @@ -226,10 +226,11 @@ type StaticWebAppSku = 'Free' | 'Standard' @export() type ContainerAppResourceConfig = { workloadProfileName: string - minReplicas: int - maxReplicas: int cpuCores: int memoryGis: int + minReplicas: int + maxReplicas: int + scaleAtConcurrentHttpRequests: int? } @export()