-
Notifications
You must be signed in to change notification settings - Fork 197
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Azure App Configuration store support (#3413)
- Loading branch information
1 parent
7dcdf2d
commit 686b23b
Showing
4 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
templates/common/infra/bicep/core/config/configstore.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
metadata description = 'Creates an Azure App Configuration store.' | ||
|
||
@description('The name for the Azure App Configuration store') | ||
param name string | ||
|
||
@description('The Azure region/location for the Azure App Configuration store') | ||
param location string = resourceGroup().location | ||
|
||
@description('Custom tags to apply to the Azure App Configuration store') | ||
param tags object = {} | ||
|
||
@description('Specifies the names of the key-value resources. The name is a combination of key and label with $ as delimiter. The label is optional.') | ||
param keyValueNames array = [] | ||
|
||
@description('Specifies the values of the key-value resources.') | ||
param keyValueValues array = [] | ||
|
||
@description('The principal ID to grant access to the Azure App Configuration store') | ||
param principalId string | ||
|
||
resource configStore 'Microsoft.AppConfiguration/configurationStores@2023-03-01' = { | ||
name: name | ||
location: location | ||
sku: { | ||
name: 'standard' | ||
} | ||
tags: tags | ||
} | ||
|
||
resource configStoreKeyValue 'Microsoft.AppConfiguration/configurationStores/keyValues@2023-03-01' = [for (item, i) in keyValueNames: { | ||
parent: configStore | ||
name: item | ||
properties: { | ||
value: keyValueValues[i] | ||
tags: tags | ||
} | ||
}] | ||
|
||
module configStoreAccess '../security/configstore-access.bicep' = { | ||
name: 'app-configuration-access' | ||
params: { | ||
configStoreName: name | ||
principalId: principalId | ||
} | ||
dependsOn: [configStore] | ||
} | ||
|
||
output endpoint string = configStore.properties.endpoint |
21 changes: 21 additions & 0 deletions
21
templates/common/infra/bicep/core/security/configstore-access.bicep
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
@description('Name of Azure App Configuration store') | ||
param configStoreName string | ||
|
||
@description('The principal ID of the service principal to assign the role to') | ||
param principalId string | ||
|
||
resource configStore 'Microsoft.AppConfiguration/configurationStores@2023-03-01' existing = { | ||
name: configStoreName | ||
} | ||
|
||
var configStoreDataReaderRole = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '516239f1-63e1-4d78-a4de-a74fb236a071') | ||
|
||
resource configStoreDataReaderRoleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { | ||
name: guid(subscription().id, resourceGroup().id, principalId, configStoreDataReaderRole) | ||
scope: configStore | ||
properties: { | ||
roleDefinitionId: configStoreDataReaderRole | ||
principalId: principalId | ||
principalType: 'ServicePrincipal' | ||
} | ||
} |