-
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.
- Loading branch information
Showing
27 changed files
with
339 additions
and
652 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
templates/todo/common/infra/bicep/app/cosmos-mongo-db-avm.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,77 @@ | ||
param accountName string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
param cosmosDatabaseName string = '' | ||
param keyVaultResourceId string | ||
param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' | ||
param collections array = [ | ||
{ | ||
name: 'TodoList' | ||
id: 'TodoList' | ||
shardKey: { | ||
keys: [ | ||
'Hash' | ||
] | ||
} | ||
indexes: [ | ||
{ | ||
key: { | ||
keys: [ | ||
'_id' | ||
] | ||
} | ||
} | ||
] | ||
} | ||
{ | ||
name: 'TodoItem' | ||
id: 'TodoItem' | ||
shardKey: { | ||
keys: [ | ||
'Hash' | ||
] | ||
} | ||
indexes: [ | ||
{ | ||
key: { | ||
keys: [ | ||
'_id' | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] | ||
|
||
var defaultDatabaseName = 'Todo' | ||
var actualDatabaseName = !empty(cosmosDatabaseName) ? cosmosDatabaseName : defaultDatabaseName | ||
|
||
module cosmos 'br/public:avm/res/document-db/database-account:0.6.0' = { | ||
name: 'cosmos' | ||
params: { | ||
locations: [ | ||
{ | ||
failoverPriority: 0 | ||
isZoneRedundant: false | ||
locationName: location | ||
} | ||
] | ||
name: accountName | ||
location: location | ||
mongodbDatabases: [ | ||
{ | ||
name: actualDatabaseName | ||
tags: tags | ||
collections: collections | ||
} | ||
] | ||
secretsExportConfiguration: { | ||
keyVaultResourceId: keyVaultResourceId | ||
primaryWriteConnectionStringSecretName: connectionStringKey | ||
} | ||
} | ||
} | ||
|
||
output connectionStringKey string = connectionStringKey | ||
output databaseName string = cosmos.outputs.name | ||
output endpoint string = cosmos.outputs.endpoint |
58 changes: 58 additions & 0 deletions
58
templates/todo/common/infra/bicep/app/cosmos-sql-db-avm.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,58 @@ | ||
param accountName string | ||
param location string = resourceGroup().location | ||
param tags object = {} | ||
param connectionStringKey string = 'AZURE-COSMOS-CONNECTION-STRING' | ||
param databaseName string = '' | ||
param keyVaultResourceId string | ||
param principalId string = '' | ||
|
||
var defaultDatabaseName = 'Todo' | ||
var actualDatabaseName = !empty(databaseName) ? databaseName : defaultDatabaseName | ||
|
||
module cosmos 'br/public:avm/res/document-db/database-account:0.6.0' = { | ||
name: 'cosmos' | ||
params: { | ||
name: accountName | ||
location: location | ||
tags: tags | ||
locations: [ | ||
{ | ||
failoverPriority: 0 | ||
locationName: location | ||
isZoneRedundant: false | ||
} | ||
] | ||
secretsExportConfiguration:{ | ||
keyVaultResourceId: keyVaultResourceId | ||
primaryWriteConnectionStringSecretName: connectionStringKey | ||
} | ||
capabilitiesToAdd: [ 'EnableServerless' ] | ||
automaticFailover: false | ||
sqlDatabases: [ | ||
{ | ||
name: actualDatabaseName | ||
containers: [ | ||
{ | ||
name: 'TodoList' | ||
paths: [ 'id' ] | ||
} | ||
{ | ||
name: 'TodoItem' | ||
paths: [ 'id' ] | ||
} | ||
] | ||
} | ||
] | ||
sqlRoleAssignmentsPrincipalIds: [ principalId ] | ||
sqlRoleDefinitions: [ | ||
{ | ||
name: 'writer' | ||
} | ||
] | ||
} | ||
} | ||
|
||
output accountName string = cosmos.outputs.name | ||
output connectionStringKey string = connectionStringKey | ||
output databaseName string = actualDatabaseName | ||
output endpoint string = cosmos.outputs.endpoint |
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
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
Oops, something went wrong.