Skip to content

Commit 9e74970

Browse files
pamelafoxCopilot
andauthored
Add missing RBAC role for token storage container when using container apps (#2724)
* Add missing RBAC role when using container apps * Add comments with role names * Update infra/main.bicep Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 305ab5b commit 9e74970

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

infra/core/host/container-apps-auth.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ resource auth 'Microsoft.App/containerApps/authConfigs@2024-10-02-preview' = {
5656
}
5757
}
5858
login: {
59-
// https://learn.microsoft.com/en-us/azure/container-apps/token-store
59+
// https://learn.microsoft.com/azure/container-apps/token-store
6060
tokenStore: {
6161
enabled: true
6262
azureBlobStorage: {

infra/main.bicep

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ module storageRoleUser 'core/security/role.bicep' = {
970970
name: 'storage-role-user'
971971
params: {
972972
principalId: principalId
973-
roleDefinitionId: '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1'
973+
roleDefinitionId: '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1' // Storage Blob Data Reader
974974
principalType: principalType
975975
}
976976
}
@@ -980,7 +980,7 @@ module storageContribRoleUser 'core/security/role.bicep' = {
980980
name: 'storage-contrib-role-user'
981981
params: {
982982
principalId: principalId
983-
roleDefinitionId: 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'
983+
roleDefinitionId: 'ba92f5b4-2d11-453d-a403-e96b0029c9fe' // Storage Blob Data Contributor
984984
principalType: principalType
985985
}
986986
}
@@ -990,7 +990,7 @@ module storageOwnerRoleUser 'core/security/role.bicep' = if (useUserUpload) {
990990
name: 'storage-owner-role-user'
991991
params: {
992992
principalId: principalId
993-
roleDefinitionId: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'
993+
roleDefinitionId: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b' // Storage Blob Data Owner
994994
principalType: principalType
995995
}
996996
}
@@ -1090,7 +1090,7 @@ module storageRoleBackend 'core/security/role.bicep' = {
10901090
principalId: (deploymentTarget == 'appservice')
10911091
? backend.outputs.identityPrincipalId
10921092
: acaBackend.outputs.identityPrincipalId
1093-
roleDefinitionId: '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1'
1093+
roleDefinitionId: '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1' // Storage Blob Data Reader
10941094
principalType: 'ServicePrincipal'
10951095
}
10961096
}
@@ -1102,7 +1102,7 @@ module storageOwnerRoleBackend 'core/security/role.bicep' = if (useUserUpload) {
11021102
principalId: (deploymentTarget == 'appservice')
11031103
? backend.outputs.identityPrincipalId
11041104
: acaBackend.outputs.identityPrincipalId
1105-
roleDefinitionId: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'
1105+
roleDefinitionId: 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b' // Storage Blob Data Owner
11061106
principalType: 'ServicePrincipal'
11071107
}
11081108
}
@@ -1112,7 +1112,7 @@ module storageRoleSearchService 'core/security/role.bicep' = if (useIntegratedVe
11121112
name: 'storage-role-searchservice'
11131113
params: {
11141114
principalId: searchService.outputs.principalId
1115-
roleDefinitionId: '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1'
1115+
roleDefinitionId: '2a2b9908-6ea1-4ae2-8e65-a410df84e7d1' // Storage Blob Data Reader
11161116
principalType: 'ServicePrincipal'
11171117
}
11181118
}
@@ -1127,6 +1127,17 @@ module storageRoleContributorSearchService 'core/security/role.bicep' = if (useI
11271127
}
11281128
}
11291129

1130+
// Necessary for the Container Apps backend to store authentication tokens in the blob storage container
1131+
module storageRoleContributorBackend 'core/security/role.bicep' = if (deploymentTarget == 'containerapps' && !empty(clientAppId)) {
1132+
scope: storageResourceGroup
1133+
name: 'storage-role-contributor-aca-backend'
1134+
params: {
1135+
principalId: acaBackend.outputs.identityPrincipalId
1136+
roleDefinitionId: 'ba92f5b4-2d11-453d-a403-e96b0029c9fe' // Storage Blob Data Contributor
1137+
principalType: 'ServicePrincipal'
1138+
}
1139+
}
1140+
11301141
// Used to issue search queries
11311142
// https://learn.microsoft.com/azure/search/search-security-rbac
11321143
module searchRoleBackend 'core/security/role.bicep' = {

0 commit comments

Comments
 (0)