Skip to content

Commit d7f070b

Browse files
committed
Revert unneeded bicep changes
1 parent 5a92db1 commit d7f070b

File tree

2 files changed

+122
-70
lines changed

2 files changed

+122
-70
lines changed
Lines changed: 66 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,86 @@
1+
metadata description = 'Creates or updates an existing Azure Container App.'
12
param name string
23
param location string = resourceGroup().location
34
param tags object = {}
45

5-
param containerAppsEnvironmentName string
6-
param containerName string = 'main'
7-
param containerRegistryName string
6+
@description('The number of CPU cores allocated to a single container instance, e.g., 0.5')
7+
param containerCpuCoreCount string = '0.5'
88

9-
@description('Minimum number of replicas to run')
10-
@minValue(1)
11-
param containerMinReplicas int = 1
12-
@description('Maximum number of replicas to run')
9+
@description('The maximum number of replicas to run. Must be at least 1.')
1310
@minValue(1)
1411
param containerMaxReplicas int = 10
1512

13+
@description('The amount of memory allocated to a single container instance, e.g., 1Gi')
14+
param containerMemory string = '1.0Gi'
15+
16+
@description('The minimum number of replicas to run. Must be at least 1 for non-consumption workloads.')
17+
param containerMinReplicas int = 1
18+
19+
@description('The name of the container')
20+
param containerName string = 'main'
21+
22+
@description('The environment name for the container apps')
23+
param containerAppsEnvironmentName string = '${containerName}env'
24+
25+
@description('The name of the container registry')
26+
param containerRegistryName string
27+
28+
@description('Hostname suffix for container registry. Set when deploying to sovereign clouds')
29+
param containerRegistryHostSuffix string = 'azurecr.io'
30+
31+
32+
@allowed(['http', 'grpc'])
33+
@description('The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC')
34+
param daprAppProtocol string = 'http'
35+
36+
@description('Enable or disable Dapr for the container app')
37+
param daprEnabled bool = false
38+
39+
@description('The Dapr app ID')
40+
param daprAppId string = containerName
41+
42+
@description('Specifies if the resource already exists')
43+
param exists bool = false
44+
45+
@description('Specifies if Ingress is enabled for the container app')
46+
param ingressEnabled bool = true
47+
48+
@description('The type of identity for the resource')
49+
@allowed(['None', 'SystemAssigned', 'UserAssigned'])
50+
param identityType string = 'None'
51+
52+
@description('The name of the user-assigned identity')
53+
param identityName string = ''
54+
55+
@description('The name of the container image')
56+
param imageName string = ''
57+
1658
@description('The secrets required for the container')
1759
@secure()
1860
param secrets object = {}
1961

62+
@description('The keyvault identities required for the container')
63+
@secure()
64+
param keyvaultIdentities object = {}
65+
2066
@description('The environment variables for the container in key value pairs')
2167
param env object = {}
2268

2369
@description('The environment variables with secret references')
2470
param envSecrets array = []
2571

72+
@description('Specifies if the resource ingress is exposed externally')
2673
param external bool = true
27-
param targetPort int = 80
28-
param exists bool
29-
30-
@description('User assigned identity name')
31-
param identityName string
32-
33-
@description('Enabled Ingress for container app')
34-
param ingressEnabled bool = true
35-
36-
// Dapr Options
37-
@description('Enable Dapr')
38-
param daprEnabled bool = false
39-
@description('Dapr app ID')
40-
param daprAppId string = containerName
41-
@allowed([ 'http', 'grpc' ])
42-
@description('Protocol used by Dapr to connect to the app, e.g. http or grpc')
43-
param daprAppProtocol string = 'http'
4474

45-
@description('CPU cores allocated to a single container instance, e.g. 0.5')
46-
param containerCpuCoreCount string = '0.5'
75+
@description('The service binds associated with the container')
76+
param serviceBinds array = []
4777

48-
@description('Memory allocated to a single container instance, e.g. 1Gi')
49-
param containerMemory string = '1.0Gi'
50-
51-
@description('Workload profile name to use for the container app when using private ingress')
52-
param workloadProfileName string = 'Warm'
78+
@description('The target port for the container')
79+
param targetPort int = 80
5380

5481
param allowedOrigins array = []
5582

56-
resource existingApp 'Microsoft.App/containerApps@2022-03-01' existing = if (exists) {
83+
resource existingApp 'Microsoft.App/containerApps@2023-05-02-preview' existing = if (exists) {
5784
name: name
5885
}
5986

@@ -70,11 +97,13 @@ module app 'container-app.bicep' = {
7097
name: name
7198
location: location
7299
tags: tags
100+
identityType: identityType
73101
identityName: identityName
74102
ingressEnabled: ingressEnabled
75103
containerName: containerName
76104
containerAppsEnvironmentName: containerAppsEnvironmentName
77105
containerRegistryName: containerRegistryName
106+
containerRegistryHostSuffix: containerRegistryHostSuffix
78107
containerCpuCoreCount: containerCpuCoreCount
79108
containerMemory: containerMemory
80109
containerMinReplicas: containerMinReplicas
@@ -83,17 +112,20 @@ module app 'container-app.bicep' = {
83112
daprAppId: daprAppId
84113
daprAppProtocol: daprAppProtocol
85114
secrets: secrets
115+
keyvaultIdentities: keyvaultIdentities
86116
allowedOrigins: allowedOrigins
87117
external: external
88118
env: concat(envAsArray, envSecrets)
89-
imageName: exists ? existingApp.properties.template.containers[0].image : ''
119+
imageName: !empty(imageName) ? imageName : exists ? existingApp.properties.template.containers[0].image : ''
90120
targetPort: targetPort
121+
serviceBinds: serviceBinds
91122
}
92123
}
93124

94125
output defaultDomain string = app.outputs.defaultDomain
95126
output imageName string = app.outputs.imageName
96127
output name string = app.outputs.name
97128
output uri string = app.outputs.uri
98-
output identityResourceId string = app.outputs.identityResourceId
129+
output id string = app.outputs.id
99130
output identityPrincipalId string = app.outputs.identityPrincipalId
131+
output identityResourceId string = app.outputs.identityResourceId

infra/core/host/container-app.bicep

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,69 +9,75 @@ param allowedOrigins array = []
99
@description('Name of the environment for container apps')
1010
param containerAppsEnvironmentName string
1111

12+
@description('CPU cores allocated to a single container instance, e.g., 0.5')
13+
param containerCpuCoreCount string = '0.5'
14+
15+
@description('The maximum number of replicas to run. Must be at least 1.')
16+
@minValue(1)
17+
param containerMaxReplicas int = 10
18+
19+
@description('Memory allocated to a single container instance, e.g., 1Gi')
20+
param containerMemory string = '1.0Gi'
21+
22+
@description('The minimum number of replicas to run. Must be at least 1.')
23+
param containerMinReplicas int = 1
24+
1225
@description('The name of the container')
1326
param containerName string = 'main'
1427

1528
@description('The name of the container registry')
16-
param containerRegistryName string
29+
param containerRegistryName string = ''
1730

1831
@description('Hostname suffix for container registry. Set when deploying to sovereign clouds')
1932
param containerRegistryHostSuffix string = 'azurecr.io'
2033

21-
@description('Minimum number of replicas to run')
22-
@minValue(1)
23-
param containerMinReplicas int = 1
24-
@description('Maximum number of replicas to run')
25-
@minValue(1)
26-
param containerMaxReplicas int = 10
34+
@description('The protocol used by Dapr to connect to the app, e.g., http or grpc')
35+
@allowed([ 'http', 'grpc' ])
36+
param daprAppProtocol string = 'http'
2737

28-
@description('The secrets required for the container')
29-
@secure()
30-
param secrets object = {}
38+
@description('The Dapr app ID')
39+
param daprAppId string = containerName
40+
41+
@description('Enable Dapr')
42+
param daprEnabled bool = false
3143

3244
@description('The environment variables for the container')
3345
param env array = []
3446

3547
@description('Specifies if the resource ingress is exposed externally')
3648
param external bool = true
3749

38-
@description('User assigned identity name')
39-
param identityName string
50+
@description('The name of the user-assigned identity')
51+
param identityName string = ''
4052

4153
@description('The type of identity for the resource')
4254
@allowed([ 'None', 'SystemAssigned', 'UserAssigned' ])
4355
param identityType string = 'None'
4456

4557
@description('The name of the container image')
46-
param imageName string
58+
param imageName string = ''
4759

48-
@description('Enabled Ingress for container app')
60+
@description('Specifies if Ingress is enabled for the container app')
4961
param ingressEnabled bool = true
5062

5163
param revisionMode string = 'Single'
5264

53-
@description('The target port for the container')
54-
param targetPort int = 80
65+
@description('The secrets required for the container')
66+
@secure()
67+
param secrets object = {}
5568

56-
// Dapr Options
57-
@description('Enable Dapr')
58-
param daprEnabled bool = false
59-
@description('Dapr app ID')
60-
param daprAppId string = containerName
61-
@allowed([ 'http', 'grpc' ])
62-
@description('Protocol used by Dapr to connect to the app, e.g. http or grpc')
63-
param daprAppProtocol string = 'http'
69+
@description('The keyvault identities required for the container')
70+
@secure()
71+
param keyvaultIdentities object = {}
6472

65-
@description('CPU cores allocated to a single container instance, e.g. 0.5')
66-
param containerCpuCoreCount string = '0.5'
73+
@description('The service binds associated with the container')
74+
param serviceBinds array = []
6775

68-
@description('Memory allocated to a single container instance, e.g. 1Gi')
69-
param containerMemory string = '1.0Gi'
76+
@description('The name of the container apps add-on to use. e.g. redis')
77+
param serviceType string = ''
7078

71-
var keyvalueSecrets = [for secret in items(secrets): {
72-
name: secret.key
73-
value: secret.value
74-
}]
79+
@description('The target port for the container')
80+
param targetPort int = 80
7581

7682
resource userIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = if (!empty(identityName)) {
7783
name: identityName
@@ -83,6 +89,17 @@ var usePrivateRegistry = !empty(identityName) && !empty(containerRegistryName)
8389
// Automatically set to `UserAssigned` when an `identityName` has been set
8490
var normalizedIdentityType = !empty(identityName) ? 'UserAssigned' : identityType
8591

92+
var keyvalueSecrets = [for secret in items(secrets): {
93+
name: secret.key
94+
value: secret.value
95+
}]
96+
97+
var keyvaultIdentitySecrets = [for secret in items(keyvaultIdentities): {
98+
name: secret.key
99+
keyVaultUrl: secret.value.keyVaultUrl
100+
identity: secret.value.identity
101+
}]
102+
86103
module containerRegistryAccess '../security/registry-access.bicep' = if (usePrivateRegistry) {
87104
name: '${deployment().name}-registry-access'
88105
params: {
@@ -92,7 +109,7 @@ module containerRegistryAccess '../security/registry-access.bicep' = if (usePriv
92109
}
93110

94111
resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
95-
name: name
112+
name: name
96113
location: location
97114
tags: tags
98115
// It is critical that the identity is granted ACR pull access before the app is created
@@ -122,7 +139,8 @@ name: name
122139
appProtocol: daprAppProtocol
123140
appPort: ingressEnabled ? targetPort : 0
124141
} : { enabled: false }
125-
secrets: keyvalueSecrets
142+
secrets: concat(keyvalueSecrets, keyvaultIdentitySecrets)
143+
service: !empty(serviceType) ? { type: serviceType } : null
126144
registries: usePrivateRegistry ? [
127145
{
128146
server: '${containerRegistryName}.${containerRegistryHostSuffix}'
@@ -131,6 +149,7 @@ name: name
131149
] : []
132150
}
133151
template: {
152+
serviceBinds: !empty(serviceBinds) ? serviceBinds : null
134153
containers: [
135154
{
136155
image: !empty(imageName) ? imageName : 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest'
@@ -155,9 +174,10 @@ resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-05-01'
155174
}
156175

157176
output defaultDomain string = containerAppsEnvironment.properties.defaultDomain
158-
output identityPrincipalId string = userIdentity.properties.principalId
159-
output identityResourceId string = resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', userIdentity.name)
177+
output identityPrincipalId string = normalizedIdentityType == 'None' ? '' : (empty(identityName) ? app.identity.principalId : userIdentity.properties.principalId)
178+
output identityResourceId string = normalizedIdentityType == 'UserAssigned' ? resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', userIdentity.name) : ''
160179
output imageName string = imageName
161180
output name string = app.name
181+
output serviceBind object = !empty(serviceType) ? { serviceId: app.id, name: name } : {}
162182
output uri string = ingressEnabled ? 'https://${app.properties.configuration.ingress.fqdn}' : ''
163183
output id string = app.id

0 commit comments

Comments
 (0)