diff --git a/avm/res/app/container-app/README.md b/avm/res/app/container-app/README.md index 236de18344..794ec770c0 100644 --- a/avm/res/app/container-app/README.md +++ b/avm/res/app/container-app/README.md @@ -484,6 +484,7 @@ module containerApp 'br/public:avm/res/app/container-app:' = { | [`scaleMinReplicas`](#parameter-scaleminreplicas) | int | Minimum number of container replicas. Defaults to 3 if not set. | | [`scaleRules`](#parameter-scalerules) | array | Scaling rules. | | [`secrets`](#parameter-secrets) | secureObject | The secrets of the Container App. | +| [`stickySessionsAffinity`](#parameter-stickysessionsaffinity) | string | Bool indicating if the Container App should enable session affinity. | | [`tags`](#parameter-tags) | object | Tags of the resource. | | [`trafficLabel`](#parameter-trafficlabel) | string | Associates a traffic label with a revision. Label name should be consist of lower case alphanumeric characters or dashes. | | [`trafficLatestRevision`](#parameter-trafficlatestrevision) | bool | Indicates that the traffic weight belongs to a latest stable revision. | @@ -834,6 +835,21 @@ The secrets of the Container App. - Type: secureObject - Default: `{}` +### Parameter: `stickySessionsAffinity` + +Bool indicating if the Container App should enable session affinity. + +- Required: No +- Type: string +- Default: `'none'` +- Allowed: + ```Bicep + [ + 'none' + 'sticky' + ] + ``` + ### Parameter: `tags` Tags of the resource. diff --git a/avm/res/app/container-app/main.bicep b/avm/res/app/container-app/main.bicep index 7ef6ed7246..8ff404eaf9 100644 --- a/avm/res/app/container-app/main.bicep +++ b/avm/res/app/container-app/main.bicep @@ -11,6 +11,13 @@ param location string = resourceGroup().location @description('Optional. Bool indicating if the App exposes an external HTTP endpoint.') param ingressExternal bool = true +@allowed([ + 'none' + 'sticky' +]) +@description('Optional. Bool indicating if the Container App should enable session affinity.') +param stickySessionsAffinity string = 'none' + @allowed([ 'auto' 'http' @@ -144,24 +151,23 @@ var builtInRoleNames = { ) } -resource avmTelemetry 'Microsoft.Resources/deployments@2023-07-01' = - if (enableTelemetry) { - name: '46d3xbcp.res.app-containerapp.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}' - properties: { - mode: 'Incremental' - template: { - '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#' - contentVersion: '1.0.0.0' - resources: [] - outputs: { - telemetry: { - type: 'String' - value: 'For more information, see https://aka.ms/avm/TelemetryInfo' - } +resource avmTelemetry 'Microsoft.Resources/deployments@2023-07-01' = if (enableTelemetry) { + name: '46d3xbcp.res.app-containerapp.${replace('-..--..-', '.', '-')}.${substring(uniqueString(deployment().name, location), 0, 4)}' + properties: { + mode: 'Incremental' + template: { + '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#' + contentVersion: '1.0.0.0' + resources: [] + outputs: { + telemetry: { + type: 'String' + value: 'For more information, see https://aka.ms/avm/TelemetryInfo' } } } } +} resource containerApp 'Microsoft.App/containerApps@2023-05-01' = { name: name @@ -180,6 +186,9 @@ resource containerApp 'Microsoft.App/containerApps@2023-05-01' = { external: ingressExternal ipSecurityRestrictions: !empty(ipSecurityRestrictions) ? ipSecurityRestrictions : null targetPort: ingressTargetPort + stickySessions: { + affinity: stickySessionsAffinity + } traffic: [ { label: trafficLabel @@ -209,17 +218,16 @@ resource containerApp 'Microsoft.App/containerApps@2023-05-01' = { } } -resource containerApp_lock 'Microsoft.Authorization/locks@2020-05-01' = - if (!empty(lock ?? {}) && lock.?kind != 'None') { - name: lock.?name ?? 'lock-${name}' - properties: { - level: lock.?kind ?? '' - notes: lock.?kind == 'CanNotDelete' - ? 'Cannot delete resource or child resources.' - : 'Cannot delete or modify the resource or child resources.' - } - scope: containerApp +resource containerApp_lock 'Microsoft.Authorization/locks@2020-05-01' = if (!empty(lock ?? {}) && lock.?kind != 'None') { + name: lock.?name ?? 'lock-${name}' + properties: { + level: lock.?kind ?? '' + notes: lock.?kind == 'CanNotDelete' + ? 'Cannot delete resource or child resources.' + : 'Cannot delete or modify the resource or child resources.' } + scope: containerApp +} resource containerApp_roleAssignments 'Microsoft.Authorization/roleAssignments@2022-04-01' = [ for (roleAssignment, index) in (roleAssignments ?? []): { diff --git a/avm/res/app/container-app/main.json b/avm/res/app/container-app/main.json index 97c1bf140a..2139556b3b 100644 --- a/avm/res/app/container-app/main.json +++ b/avm/res/app/container-app/main.json @@ -5,8 +5,8 @@ "metadata": { "_generator": { "name": "bicep", - "version": "0.26.170.59819", - "templateHash": "11829581770848647649" + "version": "0.27.1.19265", + "templateHash": "6545722573689550634" }, "name": "Container Apps", "description": "This module deploys a Container App.", @@ -149,6 +149,17 @@ "description": "Optional. Bool indicating if the App exposes an external HTTP endpoint." } }, + "stickySessionsAffinity": { + "type": "string", + "defaultValue": "none", + "allowedValues": [ + "none", + "sticky" + ], + "metadata": { + "description": "Optional. Bool indicating if the Container App should enable session affinity." + } + }, "ingressTransport": { "type": "string", "defaultValue": "auto", @@ -411,6 +422,9 @@ "external": "[parameters('ingressExternal')]", "ipSecurityRestrictions": "[if(not(empty(parameters('ipSecurityRestrictions'))), parameters('ipSecurityRestrictions'), null())]", "targetPort": "[parameters('ingressTargetPort')]", + "stickySessions": { + "affinity": "[parameters('stickySessionsAffinity')]" + }, "traffic": [ { "label": "[parameters('trafficLabel')]", diff --git a/avm/res/app/container-app/version.json b/avm/res/app/container-app/version.json index 9481fea58e..c177b1bb58 100644 --- a/avm/res/app/container-app/version.json +++ b/avm/res/app/container-app/version.json @@ -1,7 +1,7 @@ { "$schema": "https://aka.ms/bicep-registry-module-version-file-schema#", - "version": "0.2", + "version": "0.3", "pathFilters": [ "./main.json" ] -} +} \ No newline at end of file