Skip to content

Commit 49569a5

Browse files
committed
Allow usage of managed identity for backing storage
1 parent f36e278 commit 49569a5

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

templates/common/infra/bicep/core/host/functions.bicep

+14-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ param tags object = {}
77
param applicationInsightsName string = ''
88
param appServicePlanId string
99
param keyVaultName string = ''
10-
param managedIdentity bool = !empty(keyVaultName)
10+
param managedIdentity bool = !empty(keyVaultName) || storageManagedIdentity
1111
param storageAccountName string
12+
param storageManagedIdentity bool = false
1213
param virtualNetworkSubnetId string = ''
1314

1415
// Runtime Properties
@@ -56,7 +57,8 @@ module functions 'appservice.bicep' = {
5657
applicationInsightsName: applicationInsightsName
5758
appServicePlanId: appServicePlanId
5859
appSettings: union(appSettings, {
59-
AzureWebJobsStorage: 'DefaultEndpointsProtocol=https;AccountName=${storage.name};AccountKey=${storage.listKeys().keys[0].value};EndpointSuffix=${environment().suffixes.storage}'
60+
AzureWebJobsStorage__accountName: storageManagedIdentity ? storage.name : null
61+
AzureWebJobsStorage: storageManagedIdentity ? null : 'DefaultEndpointsProtocol=https;AccountName=${storage.name};AccountKey=${storage.listKeys().keys[0].value};EndpointSuffix=${environment().suffixes.storage}'
6062
FUNCTIONS_EXTENSION_VERSION: extensionVersion
6163
FUNCTIONS_WORKER_RUNTIME: runtimeName
6264
})
@@ -79,6 +81,16 @@ module functions 'appservice.bicep' = {
7981
}
8082
}
8183

84+
module storageOwnerRole '../../core/security/role.bicep' = if (storageManagedIdentity) {
85+
name: 'search-index-contrib-role-api'
86+
params: {
87+
principalId: functions.outputs.identityPrincipalId
88+
// Search Index Data Contributor
89+
roleDefinitionId: '8ebe5a00-799e-43f5-93ac-243d3dce84a7'
90+
principalType: 'ServicePrincipal'
91+
}
92+
}
93+
8294
resource storage 'Microsoft.Storage/storageAccounts@2021-09-01' existing = {
8395
name: storageAccountName
8496
}

0 commit comments

Comments
 (0)