@@ -51,6 +51,10 @@ resource containerAppsEnv 'Microsoft.App/managedEnvironments@2024-10-02-preview'
5151 name : 'collection'
5252 value : 'state'
5353 }
54+ {
55+ name : 'azureClientId'
56+ value : managedIdentity .properties .clientId
57+ }
5458 ]
5559 scopes : [
5660 containerName
@@ -63,9 +67,10 @@ resource containerMovieGallerySvcApp 'Microsoft.App/containerApps@2024-10-02-pre
6367 name : containerName
6468 location : location
6569 identity : {
66- type : 'SystemAssigned, UserAssigned'
70+ type : 'UserAssigned'
6771 userAssignedIdentities : {
6872 '${uaiAzureRambiAcrPull .id }' : {}
73+ '${managedIdentity .id }' : {}
6974 }
7075 }
7176 tags : { 'azd-service-name' : replace (containerName , '-' , '_' ) }
@@ -205,10 +210,15 @@ resource cosmosDbDatabaseCollection 'Microsoft.DocumentDB/databaseAccounts/sqlDa
205210// Assign cosmosdb account read/write access to aca system assigned identity
206211// To know more: https://learn.microsoft.com/azure/cosmos-db/how-to-setup-rbac
207212resource backendApiService_cosmosdb_role_assignment 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2022-08-15' = {
208- name : guid (subscription ().id , containerMovieGallerySvcApp .name , '00000000-0000-0000-0000-000000000002' )
213+ name : guid (
214+ subscription ().id ,
215+ 'docdbcontributor' ,
216+ containerMovieGallerySvcApp .name ,
217+ '00000000-0000-0000-0000-000000000002'
218+ )
209219 parent : cosmosDbAccount
210220 properties : {
211- principalId : containerMovieGallerySvcApp . identity .principalId
221+ principalId : managedIdentity . properties .principalId
212222 roleDefinitionId : resourceId (
213223 'Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions' ,
214224 cosmosDbAccount .name ,
@@ -218,5 +228,10 @@ resource backendApiService_cosmosdb_role_assignment 'Microsoft.DocumentDB/databa
218228 }
219229}
220230
231+ resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2022-01-31-preview' = {
232+ name : 'dapr-state-store-identity'
233+ location : location
234+ }
235+
221236output name string = containerMovieGallerySvcApp .name
222237output fqdn string = containerMovieGallerySvcApp .properties .configuration .ingress .fqdn
0 commit comments