Skip to content

Commit 4b3cd8c

Browse files
committed
Bring back unneeded changes
1 parent eac9f9d commit 4b3cd8c

File tree

8 files changed

+150
-145
lines changed

8 files changed

+150
-145
lines changed

infra/core/host/container-app-upsert.bicep

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ param containerMemory string = '1.0Gi'
5151
@description('Workload profile name to use for the container app when using private ingress')
5252
param workloadProfileName string = 'Warm'
5353

54+
param allowedOrigins array = []
55+
5456
resource existingApp 'Microsoft.App/containerApps@2022-03-01' existing = if (exists) {
5557
name: name
5658
}
@@ -81,19 +83,17 @@ module app 'container-app.bicep' = {
8183
daprAppId: daprAppId
8284
daprAppProtocol: daprAppProtocol
8385
secrets: secrets
86+
allowedOrigins: allowedOrigins
8487
external: external
8588
env: concat(envAsArray, envSecrets)
8689
imageName: exists ? existingApp.properties.template.containers[0].image : ''
8790
targetPort: targetPort
88-
// Pass workload profile name parameter
89-
workloadProfileName: workloadProfileName
9091
}
9192
}
9293

9394
output defaultDomain string = app.outputs.defaultDomain
9495
output imageName string = app.outputs.imageName
9596
output name string = app.outputs.name
96-
output hostName string = app.outputs.hostName
9797
output uri string = app.outputs.uri
9898
output identityResourceId string = app.outputs.identityResourceId
9999
output identityPrincipalId string = app.outputs.identityPrincipalId

infra/core/host/container-app.bicep

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
1+
metadata description = 'Creates a container app in an Azure Container App environment.'
12
param name string
23
param location string = resourceGroup().location
34
param tags object = {}
45

6+
@description('Allowed origins')
7+
param allowedOrigins array = []
8+
9+
@description('Name of the environment for container apps')
510
param containerAppsEnvironmentName string
11+
12+
@description('The name of the container')
613
param containerName string = 'main'
14+
15+
@description('The name of the container registry')
716
param containerRegistryName string
817

18+
@description('Hostname suffix for container registry. Set when deploying to sovereign clouds')
19+
param containerRegistryHostSuffix string = 'azurecr.io'
20+
921
@description('Minimum number of replicas to run')
1022
@minValue(1)
1123
param containerMinReplicas int = 1
@@ -20,16 +32,27 @@ param secrets object = {}
2032
@description('The environment variables for the container')
2133
param env array = []
2234

35+
@description('Specifies if the resource ingress is exposed externally')
2336
param external bool = true
24-
param imageName string
25-
param targetPort int = 80
2637

2738
@description('User assigned identity name')
2839
param identityName string
2940

41+
@description('The type of identity for the resource')
42+
@allowed([ 'None', 'SystemAssigned', 'UserAssigned' ])
43+
param identityType string = 'None'
44+
45+
@description('The name of the container image')
46+
param imageName string
47+
3048
@description('Enabled Ingress for container app')
3149
param ingressEnabled bool = true
3250

51+
param revisionMode string = 'Single'
52+
53+
@description('The target port for the container')
54+
param targetPort int = 80
55+
3356
// Dapr Options
3457
@description('Enable Dapr')
3558
param daprEnabled bool = false
@@ -45,47 +68,53 @@ param containerCpuCoreCount string = '0.5'
4568
@description('Memory allocated to a single container instance, e.g. 1Gi')
4669
param containerMemory string = '1.0Gi'
4770

48-
@description('Workload profile name to use for the container app when using private ingress')
49-
param workloadProfileName string = 'Warm'
50-
5171
var keyvalueSecrets = [for secret in items(secrets): {
5272
name: secret.key
5373
value: secret.value
5474
}]
5575

56-
resource userIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = {
76+
resource userIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' existing = if (!empty(identityName)) {
5777
name: identityName
5878
}
5979

60-
module containerRegistryAccess '../security/registry-access.bicep' = {
80+
// Private registry support requires both an ACR name and a User Assigned managed identity
81+
var usePrivateRegistry = !empty(identityName) && !empty(containerRegistryName)
82+
83+
// Automatically set to `UserAssigned` when an `identityName` has been set
84+
var normalizedIdentityType = !empty(identityName) ? 'UserAssigned' : identityType
85+
86+
module containerRegistryAccess '../security/registry-access.bicep' = if (usePrivateRegistry) {
6187
name: '${deployment().name}-registry-access'
6288
params: {
6389
containerRegistryName: containerRegistryName
64-
principalId: userIdentity.properties.principalId
90+
principalId: usePrivateRegistry ? userIdentity.properties.principalId : ''
6591
}
6692
}
6793

68-
resource app 'Microsoft.App/containerApps@2025-01-01' = {
69-
name: name
94+
resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
95+
name: name
7096
location: location
7197
tags: tags
7298
// It is critical that the identity is granted ACR pull access before the app is created
7399
// otherwise the container app will throw a provision error
74100
// This also forces us to use an user assigned managed identity since there would no way to
75101
// provide the system assigned identity with the ACR pull access before the app is created
76-
dependsOn: [ containerRegistryAccess ]
102+
dependsOn: usePrivateRegistry ? [ containerRegistryAccess ] : []
77103
identity: {
78-
type: 'UserAssigned'
79-
userAssignedIdentities: { '${userIdentity.id}': {} }
104+
type: normalizedIdentityType
105+
userAssignedIdentities: !empty(identityName) && normalizedIdentityType == 'UserAssigned' ? { '${userIdentity.id}': {} } : null
80106
}
81107
properties: {
82108
managedEnvironmentId: containerAppsEnvironment.id
83109
configuration: {
84-
activeRevisionsMode: 'single'
110+
activeRevisionsMode: revisionMode
85111
ingress: ingressEnabled ? {
86112
external: external
87113
targetPort: targetPort
88114
transport: 'auto'
115+
corsPolicy: {
116+
allowedOrigins: union([ 'https://portal.azure.com', 'https://ms.portal.azure.com' ], allowedOrigins)
117+
}
89118
} : null
90119
dapr: daprEnabled ? {
91120
enabled: true
@@ -94,12 +123,12 @@ resource app 'Microsoft.App/containerApps@2025-01-01' = {
94123
appPort: ingressEnabled ? targetPort : 0
95124
} : { enabled: false }
96125
secrets: keyvalueSecrets
97-
registries: [
126+
registries: usePrivateRegistry ? [
98127
{
99-
server: '${containerRegistry.name}.azurecr.io'
128+
server: '${containerRegistryName}.${containerRegistryHostSuffix}'
100129
identity: userIdentity.id
101130
}
102-
]
131+
] : []
103132
}
104133
template: {
105134
containers: [
@@ -121,19 +150,14 @@ resource app 'Microsoft.App/containerApps@2025-01-01' = {
121150
}
122151
}
123152

124-
resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' existing = {
153+
resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' existing = {
125154
name: containerAppsEnvironmentName
126155
}
127156

128-
// 2022-02-01-preview needed for anonymousPullEnabled
129-
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-preview' existing = {
130-
name: containerRegistryName
131-
}
132-
133157
output defaultDomain string = containerAppsEnvironment.properties.defaultDomain
158+
output identityPrincipalId string = userIdentity.properties.principalId
159+
output identityResourceId string = resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', userIdentity.name)
134160
output imageName string = imageName
135161
output name string = app.name
136-
output hostName string = app.properties.configuration.ingress.fqdn
137162
output uri string = ingressEnabled ? 'https://${app.properties.configuration.ingress.fqdn}' : ''
138-
output identityResourceId string = resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', userIdentity.name)
139-
output identityPrincipalId string = userIdentity.properties.principalId
163+
output id string = app.id

infra/core/host/container-apps.bicep

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ output environmentName string = containerAppsEnvironment.outputs.name
4646
output environmentId string = containerAppsEnvironment.outputs.resourceId
4747
output registryLoginServer string = containerRegistry.outputs.loginServer
4848
output registryName string = containerRegistry.outputs.name
49-
output registryId string = containerRegistry.outputs.resourceId

infra/core/search/search-services.bicep

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ resource search 'Microsoft.Search/searchServices@2023-11-01' = {
5555
}
5656
sku: sku
5757

58-
// https://github.com/Azure/bicep-types-az/issues/2421
5958
resource sharedPrivateLinkResource 'sharedPrivateLinkResources@2023-11-01' = [for (resourceId, i) in sharedPrivateLinkStorageAccounts: {
6059
name: 'search-shared-private-link-${i}'
6160
properties: {

infra/main.bicep

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ module acaBackend 'core/host/container-app-upsert.bicep' = if (deploymentTarget
553553
containerCpuCoreCount: '1.0'
554554
containerMemory: '2Gi'
555555
containerMinReplicas: 1
556-
//allowedOrigins: allowedOrigins
556+
allowedOrigins: allowedOrigins
557557
env: union(appEnvVariables, {
558558
// For using managed identity to access Azure resources. See https://github.com/microsoft/azure-container-apps/issues/442
559559
AZURE_CLIENT_ID: (deploymentTarget == 'containerapps') ? acaIdentity.outputs.clientId : ''
@@ -699,8 +699,6 @@ module documentIntelligence 'br/public:avm/res/cognitive-services/account:0.7.2'
699699
name: !empty(documentIntelligenceServiceName)
700700
? documentIntelligenceServiceName
701701
: '${abbrs.cognitiveServicesDocumentIntelligence}${resourceToken}'
702-
location: documentIntelligenceResourceGroupLocation
703-
tags: tags
704702
kind: 'FormRecognizer'
705703
customSubDomainName: !empty(documentIntelligenceServiceName)
706704
? documentIntelligenceServiceName
@@ -709,8 +707,10 @@ module documentIntelligence 'br/public:avm/res/cognitive-services/account:0.7.2'
709707
networkAcls: {
710708
defaultAction: 'Allow'
711709
}
712-
sku: documentIntelligenceSkuName
710+
location: documentIntelligenceResourceGroupLocation
713711
disableLocalAuth: true
712+
tags: tags
713+
sku: documentIntelligenceSkuName
714714
}
715715
}
716716

@@ -1166,9 +1166,6 @@ module isolation 'network-isolation.bicep' = if (usePrivateEndpoint) {
11661166
vnetName: '${abbrs.virtualNetworks}${resourceToken}'
11671167
useVpnGateway: useVpnGateway
11681168
deploymentTarget: deploymentTarget
1169-
// Need to check deploymentTarget due to https://github.com/Azure/bicep/issues/3990
1170-
appServicePlanName: deploymentTarget == 'appservice' ? appServicePlan.outputs.name : ''
1171-
//containerAppsEnvName: deploymentTarget == 'containerapps' ? acaManagedEnvironmentName : ''
11721169
vpnGatewayName: useVpnGateway ? '${abbrs.networkVpnGateways}${resourceToken}' : ''
11731170
dnsResolverName: useVpnGateway ? '${abbrs.privateDnsResolver}${resourceToken}' : ''
11741171
}

infra/main.parameters.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,9 +344,6 @@
344344
"webAppExists": {
345345
"value": "${SERVICE_WEB_RESOURCE_EXISTS=false}"
346346
},
347-
"azureContainerAppsWorkloadProfile": {
348-
"value": "${AZURE_CONTAINER_APPS_WORKLOAD_PROFILE=Consumption}"
349-
},
350347
"useMediaDescriberAzureCU": {
351348
"value": "${USE_MEDIA_DESCRIBER_AZURE_CU=false}"
352349
},

0 commit comments

Comments
 (0)