@@ -83,6 +83,9 @@ var resourceToken = toLower(uniqueString(subscription().id, environmentName, loc
83
83
var tags = union ({ 'azd-env-name' : environmentName }, empty (aliasTag ) ? {} : { alias : aliasTag })
84
84
var allowedOrigins = empty (allowedOrigin ) ? [webApp .outputs .uri ] : [webApp .outputs .uri , allowedOrigin ]
85
85
86
+ var indexerApiIdentityName = '${abbrs .managedIdentityUserAssignedIdentities }indexer-api-${resourceToken }'
87
+ var searchApiIdentityName = '${abbrs .managedIdentityUserAssignedIdentities }search-api-${resourceToken }'
88
+
86
89
// Organize resources in a resource group
87
90
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
88
91
name : !empty (resourceGroupName ) ? resourceGroupName : '${abbrs .resourcesResourceGroups }${environmentName }'
@@ -142,6 +145,16 @@ module webApp './core/host/staticwebapp.bicep' = {
142
145
}
143
146
}
144
147
148
+ // search API identity
149
+ module searchApiIdentity 'core/security/managed-identity.bicep' = {
150
+ name : 'search-api-identity'
151
+ scope : resourceGroup
152
+ params : {
153
+ name : searchApiIdentityName
154
+ location : location
155
+ }
156
+ }
157
+
145
158
// The search API
146
159
module searchApi './core/host/container-app.bicep' = {
147
160
name : 'search-api'
@@ -152,7 +165,7 @@ module searchApi './core/host/container-app.bicep' = {
152
165
tags : union (tags , { 'azd-service-name' : searchApiName })
153
166
containerAppsEnvironmentName : containerApps .outputs .environmentName
154
167
containerRegistryName : containerApps .outputs .registryName
155
- identityType : 'SystemAssigned'
168
+ identityName : searchApiIdentityName
156
169
allowedOrigins : allowedOrigins
157
170
containerCpuCoreCount : '1.0'
158
171
containerMemory : '2.0Gi'
@@ -200,15 +213,29 @@ module searchApi './core/host/container-app.bicep' = {
200
213
value : storageContainerName
201
214
}
202
215
{
203
- name : 'APPLICATIONINSIGHTS_CONNECTION_STRING'
204
- secretRef : 'appinsights-cs'
216
+ name : 'APPLICATIONINSIGHTS_CONNECTION_STRING'
217
+ secretRef : 'appinsights-cs'
218
+ }
219
+ {
220
+ name : 'AZURE_CLIENT_ID'
221
+ value : searchApiIdentity .outputs .clientId
205
222
}
206
223
]
207
224
imageName : !empty (searchApiImageName ) ? searchApiImageName : 'nginx:latest'
208
225
targetPort : 3000
209
226
}
210
227
}
211
228
229
+ // Indexer API identity
230
+ module indexerApiIdentity 'core/security/managed-identity.bicep' = {
231
+ name : 'indexer-api-identity'
232
+ scope : resourceGroup
233
+ params : {
234
+ name : indexerApiIdentityName
235
+ location : location
236
+ }
237
+ }
238
+
212
239
// The indexer API
213
240
module indexerApi './core/host/container-app.bicep' = {
214
241
name : 'indexer-api'
@@ -219,7 +246,7 @@ module indexerApi './core/host/container-app.bicep' = {
219
246
tags : union (tags , { 'azd-service-name' : indexerApiName })
220
247
containerAppsEnvironmentName : containerApps .outputs .environmentName
221
248
containerRegistryName : containerApps .outputs .registryName
222
- identityType : 'SystemAssigned'
249
+ identityName : indexerApiIdentityName
223
250
containerCpuCoreCount : '1.0'
224
251
containerMemory : '2.0Gi'
225
252
secrets : [
@@ -266,8 +293,12 @@ module indexerApi './core/host/container-app.bicep' = {
266
293
value : storageContainerName
267
294
}
268
295
{
269
- name : 'APPLICATIONINSIGHTS_CONNECTION_STRING'
270
- secretRef : 'appinsights-cs'
296
+ name : 'APPLICATIONINSIGHTS_CONNECTION_STRING'
297
+ secretRef : 'appinsights-cs'
298
+ }
299
+ {
300
+ name : 'AZURE_CLIENT_ID'
301
+ value : indexerApiIdentity .outputs .clientId
271
302
}
272
303
]
273
304
imageName : !empty (indexerApiImageName ) ? indexerApiImageName : 'nginx:latest'
@@ -505,3 +536,6 @@ output INDEXER_API_URI string = indexerApi.outputs.uri
505
536
506
537
output ALLOWED_ORIGINS string = join (allowedOrigins , ',' )
507
538
output BACKEND_URI string = !empty (backendUri ) ? backendUri : searchApi .outputs .uri
539
+
540
+ output INDEXER_PRINCIPAL_ID string = indexerApi .outputs .identityPrincipalId
541
+ output SEARCH_API_PRINCIPAL_ID string = searchApi .outputs .identityPrincipalId
0 commit comments