From f4cb3b322aae4b3f85ed8dfb53187c0dfd7b91f4 Mon Sep 17 00:00:00 2001 From: Michiel Van Herreweghe <169037533+MichielVanHerreweghe@users.noreply.github.com> Date: Wed, 15 May 2024 16:03:26 +0200 Subject: [PATCH 1/4] Added stickySessionsAffinity parameter --- avm/res/app/container-app/main.bicep | 56 ++++++++++++++++------------ 1 file changed, 32 insertions(+), 24 deletions(-) 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 ?? []): { From 10223c1c580163d303732586a2926dcfff53dca3 Mon Sep 17 00:00:00 2001 From: Michiel Van Herreweghe <169037533+MichielVanHerreweghe@users.noreply.github.com> Date: Wed, 15 May 2024 16:04:20 +0200 Subject: [PATCH 2/4] Added stickySessionsAffinity parameter documentation --- avm/res/app/container-app/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/avm/res/app/container-app/README.md b/avm/res/app/container-app/README.md index 236de18344..ed7bfb6b07 100644 --- a/avm/res/app/container-app/README.md +++ b/avm/res/app/container-app/README.md @@ -471,6 +471,7 @@ module containerApp 'br/public:avm/res/app/container-app:' = { | [`ingressExternal`](#parameter-ingressexternal) | bool | Bool indicating if the App exposes an external HTTP endpoint. | | [`ingressTargetPort`](#parameter-ingresstargetport) | int | Target Port in containers for traffic from ingress. | | [`ingressTransport`](#parameter-ingresstransport) | string | Ingress transport protocol. | +| [`stickySessionsAffinity`](#parameter-stickySessionsAffinity) | string | Bool indicating if the Container App should enable session affinity. | | [`initContainersTemplate`](#parameter-initcontainerstemplate) | array | List of specialized containers that run before app containers. | | [`ipSecurityRestrictions`](#parameter-ipsecurityrestrictions) | array | Rules to restrict incoming IP address. | | [`location`](#parameter-location) | string | Location for all Resources. | @@ -601,6 +602,19 @@ Ingress transport protocol. ] ``` +### Parameter: `stickySessionsAffinity` + +- Required: No +- Type: string +- Default: `'none'` +- Allowed: + ```Bicep + [ + 'none' + 'sticky' + ] + ``` + ### Parameter: `initContainersTemplate` List of specialized containers that run before app containers. From 9754d2d8f7f89b5fbc5d47487173f79d0ba800c2 Mon Sep 17 00:00:00 2001 From: Michiel Van Herreweghe <169037533+MichielVanHerreweghe@users.noreply.github.com> Date: Wed, 15 May 2024 16:40:04 +0200 Subject: [PATCH 3/4] Adjusted version from 0.2 to 0.3 --- avm/res/app/container-app/version.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 3c96de7cab7d4a746f0ce7981bea965c855983ee Mon Sep 17 00:00:00 2001 From: Michiel Van Herreweghe <169037533+MichielVanHerreweghe@users.noreply.github.com> Date: Wed, 15 May 2024 17:11:43 +0200 Subject: [PATCH 4/4] Generated documentation and ARM template --- avm/res/app/container-app/README.md | 30 +++++++++++++++-------------- avm/res/app/container-app/main.json | 18 +++++++++++++++-- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/avm/res/app/container-app/README.md b/avm/res/app/container-app/README.md index ed7bfb6b07..794ec770c0 100644 --- a/avm/res/app/container-app/README.md +++ b/avm/res/app/container-app/README.md @@ -471,7 +471,6 @@ module containerApp 'br/public:avm/res/app/container-app:' = { | [`ingressExternal`](#parameter-ingressexternal) | bool | Bool indicating if the App exposes an external HTTP endpoint. | | [`ingressTargetPort`](#parameter-ingresstargetport) | int | Target Port in containers for traffic from ingress. | | [`ingressTransport`](#parameter-ingresstransport) | string | Ingress transport protocol. | -| [`stickySessionsAffinity`](#parameter-stickySessionsAffinity) | string | Bool indicating if the Container App should enable session affinity. | | [`initContainersTemplate`](#parameter-initcontainerstemplate) | array | List of specialized containers that run before app containers. | | [`ipSecurityRestrictions`](#parameter-ipsecurityrestrictions) | array | Rules to restrict incoming IP address. | | [`location`](#parameter-location) | string | Location for all Resources. | @@ -485,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. | @@ -602,19 +602,6 @@ Ingress transport protocol. ] ``` -### Parameter: `stickySessionsAffinity` - -- Required: No -- Type: string -- Default: `'none'` -- Allowed: - ```Bicep - [ - 'none' - 'sticky' - ] - ``` - ### Parameter: `initContainersTemplate` List of specialized containers that run before app containers. @@ -848,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.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')]",