@@ -169,6 +169,13 @@ var publicUrl = isCustomDomainSet
169169 : 'https://${appGatewayContainerAppName }.${containerAppsEnvironment .outputs .defaultDomainName }'
170170var cdnUrl = publicUrl
171171
172+ // Back-office is reachable on its custom domain when set, else on the auto-generated ACA FQDN. Both code
173+ // paths must agree on the same hostname for Easy Auth redirect URLs and for the application's host-aware
174+ // routing (HostScopedSinglePageApp, BackOffice__Host, Hostnames__BackOffice).
175+ var backOfficeHost = backOfficeDomainName != ''
176+ ? backOfficeDomainName
177+ : 'back-office.${containerAppsEnvironment .outputs .defaultDomainName }'
178+
172179// Account
173180
174181var accountIdentityName = '${clusterResourceGroupName }-account'
@@ -268,7 +275,7 @@ var accountApiEnvironmentVariables = concat(accountEnvironmentVariables, [
268275 }
269276 {
270277 name : 'BackOffice__Host'
271- value : backOfficeDomainName
278+ value : backOfficeHost
272279 }
273280 {
274281 name : 'BackOffice__GroupId'
@@ -321,26 +328,55 @@ module accountApi '../modules/container-app.bicep' = {
321328 userAssignedIdentityName : accountIdentityName
322329 ingress : true
323330 hasProbesEndpoint : true
324- additionalDomainName : backOfficeDomainName
325- external : backOfficeDomainName != ''
331+ external : false
326332 revisionSuffix : revisionSuffix
327333 environmentVariables : accountApiEnvironmentVariables
328334 }
329335 dependsOn : [accountWorkers ]
330336}
331337
332- module accountApiAuthConfig '../modules/container-app-auth-config.bicep' = if (backOfficeDomainName != '' && backOfficeEntraClientId != '' ) {
333- name : '${clusterResourceGroupName }-account-api-auth-config'
338+ // Back-office runs the same image as account-api on a separate external container app. Easy Auth is bound here
339+ // only (RedirectToLoginPage), so account-api can stay internal-only and reachable solely through AppGateway.
340+ module backOffice '../modules/container-app.bicep' = {
341+ name : '${clusterResourceGroupName }-back-office-container-app'
342+ scope : clusterResourceGroup
343+ params : {
344+ name : 'back-office'
345+ location : location
346+ tags : tags
347+ clusterResourceGroupName : clusterResourceGroupName
348+ containerAppsEnvironmentId : containerAppsEnvironment .outputs .environmentId
349+ containerAppsEnvironmentName : containerAppsEnvironment .outputs .name
350+ containerRegistryName : containerRegistryName
351+ containerImageName : 'account-api'
352+ containerImageTag : accountVersion
353+ cpu : '0.1'
354+ memory : '0.2Gi'
355+ minReplicas : 0
356+ maxReplicas : 1
357+ userAssignedIdentityName : accountIdentityName
358+ ingress : true
359+ hasProbesEndpoint : true
360+ additionalDomainName : backOfficeDomainName
361+ external : true
362+ revisionSuffix : revisionSuffix
363+ environmentVariables : accountApiEnvironmentVariables
364+ }
365+ dependsOn : [accountApi ]
366+ }
367+
368+ module backOfficeAuthConfig '../modules/container-app-auth-config.bicep' = if (backOfficeEntraClientId != '' ) {
369+ name : '${clusterResourceGroupName }-back-office-auth-config'
334370 scope : clusterResourceGroup
335371 params : {
336- containerAppName : 'account-api '
372+ containerAppName : 'back-office '
337373 tenantId : subscription ().tenantId
338374 clientId : backOfficeEntraClientId
339375 allowedExternalRedirectUrls : [
340- 'https://${backOfficeDomainName }/.auth/login/aad/callback'
376+ 'https://${backOfficeHost }/.auth/login/aad/callback'
341377 ]
342378 }
343- dependsOn : [accountApi ]
379+ dependsOn : [backOffice ]
344380}
345381
346382// Main
@@ -546,7 +582,7 @@ module appGateway '../modules/container-app.bicep' = {
546582 }
547583 {
548584 name : 'Hostnames__BackOffice'
549- value : backOfficeDomainName
585+ value : backOfficeHost
550586 }
551587 ]
552588 }
0 commit comments