Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Container app add on and update api version #3053

Merged
merged 3 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion avm/res/app/container-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This module deploys a Container App.

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.App/containerApps` | [2023-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.App/2023-05-01/containerApps) |
| `Microsoft.App/containerApps` | [2024-03-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.App/2024-03-01/containerApps) |
| `Microsoft.Authorization/locks` | [2020-05-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-05-01/locks) |
| `Microsoft.Authorization/roleAssignments` | [2022-04-01](https://learn.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2022-04-01/roleAssignments) |

Expand Down Expand Up @@ -674,6 +674,7 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
| [`disableIngress`](#parameter-disableingress) | bool | Bool to disable all ingress traffic for the container app. |
| [`enableTelemetry`](#parameter-enabletelemetry) | bool | Enable/Disable usage telemetry for module. |
| [`exposedPort`](#parameter-exposedport) | int | Exposed Port in containers for TCP traffic from ingress. |
| [`includeAddOns`](#parameter-includeaddons) | bool | Toggle to include the service configuration. |
| [`ingressAllowInsecure`](#parameter-ingressallowinsecure) | bool | Bool indicating if HTTP connections to is allowed. If set to false HTTP connections are automatically redirected to HTTPS connections. |
| [`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. |
Expand All @@ -691,6 +692,8 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
| [`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. |
| [`service`](#parameter-service) | object | Dev ContainerApp service type. |
| [`serviceBinds`](#parameter-servicebinds) | array | List of container app services bound to the 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. |
Expand Down Expand Up @@ -1183,6 +1186,14 @@ Exposed Port in containers for TCP traffic from ingress.
- Type: int
- Default: `0`

### Parameter: `includeAddOns`

Toggle to include the service configuration.

- Required: No
- Type: bool
- Default: `False`

### Parameter: `ingressAllowInsecure`

Bool indicating if HTTP connections to is allowed. If set to false HTTP connections are automatically redirected to HTTPS connections.
Expand Down Expand Up @@ -1465,6 +1476,42 @@ The secrets of the Container App.
- Type: secureObject
- Default: `{}`

### Parameter: `service`

Dev ContainerApp service type.

- Required: No
- Type: object
- Default: `{}`

### Parameter: `serviceBinds`

List of container app services bound to the app.

- Required: No
- Type: array

**Required parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`name`](#parameter-servicebindsname) | string | The name of the service. |
| [`serviceId`](#parameter-servicebindsserviceid) | string | The service ID. |

### Parameter: `serviceBinds.name`

The name of the service.

- Required: Yes
- Type: string

### Parameter: `serviceBinds.serviceId`

The service ID.

- Required: Yes
- Type: string

### Parameter: `stickySessionsAffinity`

Bool indicating if the Container App should enable session affinity.
Expand Down
21 changes: 20 additions & 1 deletion avm/res/app/container-app/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ param stickySessionsAffinity string = 'none'
@description('Optional. Ingress transport protocol.')
param ingressTransport string = 'auto'

@description('Optional. Dev ContainerApp service type.')
param service object = {}

@description('Optional. Toggle to include the service configuration.')
param includeAddOns bool = false

@description('Optional. Bool indicating if HTTP connections to is allowed. If set to false HTTP connections are automatically redirected to HTTPS connections.')
param ingressAllowInsecure bool = true

Expand All @@ -56,6 +62,9 @@ param scaleMinReplicas int = 3
@description('Optional. Scaling rules.')
param scaleRules array = []

@description('Optional. List of container app services bound to the app.')
param serviceBinds serviceBind[]?

@allowed([
'Multiple'
'Single'
Expand Down Expand Up @@ -195,7 +204,7 @@ resource avmTelemetry 'Microsoft.Resources/deployments@2024-03-01' = if (enableT
}
}

resource containerApp 'Microsoft.App/containerApps@2023-05-01' = {
resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
name: name
tags: tags
location: location
Expand Down Expand Up @@ -240,6 +249,7 @@ resource containerApp 'Microsoft.App/containerApps@2023-05-01' = {
: null
transport: ingressTransport
}
service: (includeAddOns && !empty(service)) ? service : null
maxInactiveRevisions: maxInactiveRevisions
registries: !empty(registries) ? registries : null
secrets: secretList
Expand All @@ -253,6 +263,7 @@ resource containerApp 'Microsoft.App/containerApps@2023-05-01' = {
minReplicas: scaleMinReplicas
rules: !empty(scaleRules) ? scaleRules : null
}
serviceBinds: (includeAddOns && !empty(serviceBinds)) ? serviceBinds : null
volumes: !empty(volumes) ? volumes : null
}
workloadProfileName: workloadProfileName
Expand Down Expand Up @@ -376,6 +387,14 @@ type container = {
volumeMounts: volumeMount[]?
}

type serviceBind = {
@description('Required. The name of the service.')
name: string

@description('Required. The service ID.')
serviceId: string
}

type environmentVar = {
@description('Required. Environment variable name.')
name: string
Expand Down
51 changes: 47 additions & 4 deletions avm/res/app/container-app/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "9639124785872259212"
"templateHash": "16433987478692764186"
},
"name": "Container Apps",
"description": "This module deploys a Container App.",
Expand Down Expand Up @@ -208,6 +208,23 @@
}
}
},
"serviceBind": {
"type": "object",
"properties": {
"name": {
"type": "string",
"metadata": {
"description": "Required. The name of the service."
}
},
"serviceId": {
"type": "string",
"metadata": {
"description": "Required. The service ID."
}
}
}
},
"environmentVar": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -553,6 +570,20 @@
"description": "Optional. Ingress transport protocol."
}
},
"service": {
"type": "object",
"defaultValue": {},
"metadata": {
"description": "Optional. Dev ContainerApp service type."
}
},
"includeAddOns": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Optional. Toggle to include the service configuration."
}
},
"ingressAllowInsecure": {
"type": "bool",
"defaultValue": true,
Expand Down Expand Up @@ -588,6 +619,16 @@
"description": "Optional. Scaling rules."
}
},
"serviceBinds": {
"type": "array",
"items": {
"$ref": "#/definitions/serviceBind"
},
"nullable": true,
"metadata": {
"description": "Optional. List of container app services bound to the app."
}
},
"activeRevisionsMode": {
"type": "string",
"defaultValue": "Single",
Expand Down Expand Up @@ -795,7 +836,7 @@
},
"containerApp": {
"type": "Microsoft.App/containerApps",
"apiVersion": "2023-05-01",
"apiVersion": "2024-03-01",
"name": "[parameters('name')]",
"tags": "[parameters('tags')]",
"location": "[parameters('location')]",
Expand All @@ -806,6 +847,7 @@
"activeRevisionsMode": "[parameters('activeRevisionsMode')]",
"dapr": "[if(not(empty(parameters('dapr'))), parameters('dapr'), null())]",
"ingress": "[if(parameters('disableIngress'), null(), createObject('allowInsecure', if(not(equals(parameters('ingressTransport'), 'tcp')), parameters('ingressAllowInsecure'), false()), 'customDomains', if(not(empty(parameters('customDomains'))), parameters('customDomains'), null()), 'corsPolicy', if(and(not(equals(parameters('corsPolicy'), null())), not(equals(parameters('ingressTransport'), 'tcp'))), createObject('allowCredentials', coalesce(tryGet(parameters('corsPolicy'), 'allowCredentials'), false()), 'allowedHeaders', coalesce(tryGet(parameters('corsPolicy'), 'allowedHeaders'), createArray()), 'allowedMethods', coalesce(tryGet(parameters('corsPolicy'), 'allowedMethods'), createArray()), 'allowedOrigins', coalesce(tryGet(parameters('corsPolicy'), 'allowedOrigins'), createArray()), 'exposeHeaders', coalesce(tryGet(parameters('corsPolicy'), 'exposeHeaders'), createArray()), 'maxAge', tryGet(parameters('corsPolicy'), 'maxAge')), null()), 'clientCertificateMode', if(not(equals(parameters('ingressTransport'), 'tcp')), parameters('clientCertificateMode'), null()), 'exposedPort', parameters('exposedPort'), 'external', parameters('ingressExternal'), 'ipSecurityRestrictions', if(not(empty(parameters('ipSecurityRestrictions'))), parameters('ipSecurityRestrictions'), null()), 'targetPort', parameters('ingressTargetPort'), 'stickySessions', createObject('affinity', parameters('stickySessionsAffinity')), 'traffic', if(not(equals(parameters('ingressTransport'), 'tcp')), createArray(createObject('label', parameters('trafficLabel'), 'latestRevision', parameters('trafficLatestRevision'), 'revisionName', parameters('trafficRevisionName'), 'weight', parameters('trafficWeight'))), null()), 'transport', parameters('ingressTransport')))]",
"service": "[if(and(parameters('includeAddOns'), not(empty(parameters('service')))), parameters('service'), null())]",
"maxInactiveRevisions": "[parameters('maxInactiveRevisions')]",
"registries": "[if(not(empty(parameters('registries'))), parameters('registries'), null())]",
"secrets": "[variables('secretList')]"
Expand All @@ -819,6 +861,7 @@
"minReplicas": "[parameters('scaleMinReplicas')]",
"rules": "[if(not(empty(parameters('scaleRules'))), parameters('scaleRules'), null())]"
},
"serviceBinds": "[if(and(parameters('includeAddOns'), not(empty(parameters('serviceBinds')))), parameters('serviceBinds'), null())]",
"volumes": "[if(not(empty(parameters('volumes'))), parameters('volumes'), null())]"
},
"workloadProfileName": "[parameters('workloadProfileName')]"
Expand Down Expand Up @@ -895,14 +938,14 @@
"metadata": {
"description": "The principal ID of the system assigned identity."
},
"value": "[coalesce(tryGet(tryGet(reference('containerApp', '2023-05-01', 'full'), 'identity'), 'principalId'), '')]"
"value": "[coalesce(tryGet(tryGet(reference('containerApp', '2024-03-01', 'full'), 'identity'), 'principalId'), '')]"
},
"location": {
"type": "string",
"metadata": {
"description": "The location the resource was deployed into."
},
"value": "[reference('containerApp', '2023-05-01', 'full').location]"
"value": "[reference('containerApp', '2024-03-01', 'full').location]"
}
}
}
4 changes: 2 additions & 2 deletions avm/res/app/container-app/version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://aka.ms/bicep-registry-module-version-file-schema#",
"version": "0.8",
"version": "0.9",
"pathFilters": [
"./main.json"
]
}
}