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 - Removed workaround for secrets #4426

Merged
merged 2 commits into from
Feb 11, 2025
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
156 changes: 77 additions & 79 deletions avm/res/app/container-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
]
environmentResourceId: '<environmentResourceId>'
name: 'acamin001'
// Non-required parameters
location: '<location>'
}
}
```
Expand Down Expand Up @@ -95,10 +93,6 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
},
"name": {
"value": "acamin001"
},
// Non-required parameters
"location": {
"value": "<location>"
}
}
}
Expand Down Expand Up @@ -127,8 +121,6 @@ param containers = [
]
param environmentResourceId = '<environmentResourceId>'
param name = 'acamin001'
// Non-required parameters
param location = '<location>'
```

</details>
Expand Down Expand Up @@ -162,7 +154,6 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
name: 'acapriv001'
// Non-required parameters
disableIngress: true
location: '<location>'
}
}
```
Expand Down Expand Up @@ -201,9 +192,6 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
// Non-required parameters
"disableIngress": {
"value": true
},
"location": {
"value": "<location>"
}
}
}
Expand Down Expand Up @@ -234,7 +222,6 @@ param environmentResourceId = '<environmentResourceId>'
param name = 'acapriv001'
// Non-required parameters
param disableIngress = true
param location = '<location>'
```

</details>
Expand Down Expand Up @@ -335,19 +322,17 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
]
}
}
secrets: {
secureList: [
{
name: 'containerappstoredsecret'
value: '<value>'
}
{
identity: '<identity>'
keyVaultUrl: '<keyVaultUrl>'
name: 'keyvaultstoredsecret'
}
]
}
secrets: [
{
name: 'containerappstoredsecret'
value: '<value>'
}
{
identity: '<identity>'
keyVaultUrl: '<keyVaultUrl>'
name: 'keyvaultstoredsecret'
}
]
tags: {
Env: 'test'
'hidden-title': 'This is visible in the resource name'
Expand Down Expand Up @@ -467,19 +452,17 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
}
},
"secrets": {
"value": {
"secureList": [
{
"name": "containerappstoredsecret",
"value": "<value>"
},
{
"identity": "<identity>",
"keyVaultUrl": "<keyVaultUrl>",
"name": "keyvaultstoredsecret"
}
]
}
"value": [
{
"name": "containerappstoredsecret",
"value": "<value>"
},
{
"identity": "<identity>",
"keyVaultUrl": "<keyVaultUrl>",
"name": "keyvaultstoredsecret"
}
]
},
"tags": {
"value": {
Expand Down Expand Up @@ -583,19 +566,17 @@ param runtime = {
]
}
}
param secrets = {
secureList: [
{
name: 'containerappstoredsecret'
value: '<value>'
}
{
identity: '<identity>'
keyVaultUrl: '<keyVaultUrl>'
name: 'keyvaultstoredsecret'
}
]
}
param secrets = [
{
name: 'containerappstoredsecret'
value: '<value>'
}
{
identity: '<identity>'
keyVaultUrl: '<keyVaultUrl>'
name: 'keyvaultstoredsecret'
}
]
param tags = {
Env: 'test'
'hidden-title': 'This is visible in the resource name'
Expand Down Expand Up @@ -643,7 +624,6 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
ingressExternal: false
ingressTargetPort: 80
ingressTransport: 'tcp'
location: '<location>'
}
}
```
Expand Down Expand Up @@ -700,9 +680,6 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
},
"ingressTransport": {
"value": "tcp"
},
"location": {
"value": "<location>"
}
}
}
Expand Down Expand Up @@ -743,7 +720,6 @@ param ingressAllowInsecure = false
param ingressExternal = false
param ingressTargetPort = 80
param ingressTransport = 'tcp'
param location = '<location>'
```

</details>
Expand Down Expand Up @@ -795,11 +771,6 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
// Non-required parameters
ingressAllowInsecure: false
ingressExternal: false
location: '<location>'
lock: {
kind: 'CanNotDelete'
name: 'myCustomLockName'
}
managedIdentities: {
userAssignedResourceIds: [
'<managedIdentityResourceId>'
Expand Down Expand Up @@ -868,15 +839,6 @@ module containerApp 'br/public:avm/res/app/container-app:<version>' = {
"ingressExternal": {
"value": false
},
"location": {
"value": "<location>"
},
"lock": {
"value": {
"kind": "CanNotDelete",
"name": "myCustomLockName"
}
},
"managedIdentities": {
"value": {
"userAssignedResourceIds": [
Expand Down Expand Up @@ -937,11 +899,6 @@ param name = 'acawaf001'
// Non-required parameters
param ingressAllowInsecure = false
param ingressExternal = false
param location = '<location>'
param lock = {
kind: 'CanNotDelete'
name: 'myCustomLockName'
}
param managedIdentities = {
userAssignedResourceIds: [
'<managedIdentityResourceId>'
Expand Down Expand Up @@ -997,7 +954,7 @@ param tags = {
| [`scaleMaxReplicas`](#parameter-scalemaxreplicas) | int | Maximum number of container replicas. Defaults to 10 if not set. |
| [`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. |
| [`secrets`](#parameter-secrets) | array | 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. |
Expand Down Expand Up @@ -1970,8 +1927,49 @@ Scaling rules.
The secrets of the Container App.

- Required: No
- Type: secureObject
- Default: `{}`
- Type: array

**Conditional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`keyVaultUrl`](#parameter-secretskeyvaulturl) | string | Azure Key Vault URL pointing to the secret referenced by the Container App Job. Required if `value` is null. |
| [`value`](#parameter-secretsvalue) | securestring | The secret value, if not fetched from Key Vault. Required if `keyVaultUrl` is not null. |

**Optional parameters**

| Parameter | Type | Description |
| :-- | :-- | :-- |
| [`identity`](#parameter-secretsidentity) | string | Resource ID of a managed identity to authenticate with Azure Key Vault, or System to use a system-assigned identity. |
| [`name`](#parameter-secretsname) | string | The name of the secret. |

### Parameter: `secrets.keyVaultUrl`

Azure Key Vault URL pointing to the secret referenced by the Container App Job. Required if `value` is null.

- Required: No
- Type: string

### Parameter: `secrets.value`

The secret value, if not fetched from Key Vault. Required if `keyVaultUrl` is not null.

- Required: No
- Type: securestring

### Parameter: `secrets.identity`

Resource ID of a managed identity to authenticate with Azure Key Vault, or System to use a system-assigned identity.

- Required: No
- Type: string

### Parameter: `secrets.name`

The name of the secret.

- Required: No
- Type: string

### Parameter: `service`

Expand Down
50 changes: 34 additions & 16 deletions avm/res/app/container-app/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,7 @@ param containers containerType[]
param initContainersTemplate array = []

@description('Optional. The secrets of the Container App.')
@secure()
param secrets object = {}
param secrets secretType[]?

@description('Optional. User friendly suffix that is appended to the revision name.')
param revisionSuffix string = ''
Expand All @@ -147,8 +146,6 @@ param volumes array = []
@description('Optional. Workload profile name to pin for container app execution.')
param workloadProfileName string = ''

var secretList = !empty(secrets) ? secrets.secureList : []

var formattedUserAssignedIdentities = reduce(
map((managedIdentities.?userAssignedResourceIds ?? []), (id) => { '${id}': {} }),
{},
Expand Down Expand Up @@ -261,20 +258,24 @@ resource containerApp 'Microsoft.App/containerApps@2024-10-02-preview' = {
service: (includeAddOns && !empty(service)) ? service : null
maxInactiveRevisions: maxInactiveRevisions
registries: !empty(registries) ? registries : null
secrets: secretList
secrets: secrets
runtime: {
dotnet: !empty(runtime.?dotnet) ? {
autoConfigureDataProtection: runtime.?dotnet.autoConfigureDataProtection
} : null
java: !empty(runtime.?java) ? {
enableMetrics: runtime.?java.enableMetrics
javaAgent: {
enabled: runtime.?java.enableJavaAgent
logging: {
loggerSettings: runtime.?java.?loggerSettings
dotnet: !empty(runtime.?dotnet)
? {
autoConfigureDataProtection: runtime.?dotnet.autoConfigureDataProtection
}
}
} : null
: null
java: !empty(runtime.?java)
? {
enableMetrics: runtime.?java.enableMetrics
javaAgent: {
enabled: runtime.?java.enableJavaAgent
logging: {
loggerSettings: runtime.?java.?loggerSettings
}
}
}
: null
}
}
template: {
Expand Down Expand Up @@ -544,3 +545,20 @@ type runtimeType = {
}[]?
}?
}?

@export()
@description('The type for a secret.')
type secretType = {
@description('Optional. Resource ID of a managed identity to authenticate with Azure Key Vault, or System to use a system-assigned identity.')
identity: string?

@description('Conditional. Azure Key Vault URL pointing to the secret referenced by the Container App Job. Required if `value` is null.')
keyVaultUrl: string?

@description('Optional. The name of the secret.')
name: string?

@description('Conditional. The secret value, if not fetched from Key Vault. Required if `keyVaultUrl` is not null.')
@secure()
value: string?
}
Loading
Loading