-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add schema support for cosmos db #4780
base: main
Are you sure you want to change the base?
Changes from 5 commits
78ee19b
f01ca41
b6a3dd8
e39f4fa
1ec39ab
4b63d38
7635633
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,8 @@ module containerAppsEnvironment 'br/public:avm/res/app/managed-environment:0.4.5 | |
{{- end}} | ||
|
||
{{- if .DbCosmosMongo}} | ||
module cosmos 'br/public:avm/res/document-db/database-account:0.8.1' = { | ||
name: 'cosmos' | ||
module cosmosMongo 'br/public:avm/res/document-db/database-account:0.8.1' = { | ||
name: 'cosmosMongo' | ||
params: { | ||
name: '${abbrs.documentDBDatabaseAccounts}${resourceToken}' | ||
location: location | ||
|
@@ -101,6 +101,58 @@ module cosmos 'br/public:avm/res/document-db/database-account:0.8.1' = { | |
} | ||
{{- end}} | ||
|
||
{{- if .DbCosmos }} | ||
module cosmos 'br/public:avm/res/document-db/database-account:0.8.1' = { | ||
name: 'cosmos' | ||
params: { | ||
name: '${abbrs.documentDBDatabaseAccounts}${resourceToken}' | ||
weikanglim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
tags: tags | ||
location: location | ||
locations: [ | ||
{ | ||
failoverPriority: 0 | ||
isZoneRedundant: false | ||
locationName: location | ||
} | ||
] | ||
networkRestrictions: { | ||
ipRules: [] | ||
virtualNetworkRules: [] | ||
publicNetworkAccess: 'Enabled' | ||
} | ||
sqlDatabases: [ | ||
{ | ||
name: '{{ .DbCosmos.DatabaseName }}' | ||
containers: [ | ||
{{- range .DbCosmos.Containers}} | ||
{ | ||
name: '{{ .ContainerName }}' | ||
paths: [ | ||
{{- range $path := .PartitionKeyPaths}} | ||
'{{ $path }}' | ||
{{- end}} | ||
] | ||
} | ||
{{- end}} | ||
] | ||
Comment on lines
+126
to
+137
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've had time to look into this more, and I'm wondering if we should not specify any container properties. For non-Java languages, this is usually created as a dataplane operation within the SDK clients. I think there's a similar concept in Azure Spring Cloud for CosmosDB, where the annotation would create the container on boot time. Would you be able to confirm and see if we can avoid adding this entirely? |
||
} | ||
] | ||
sqlRoleAssignmentsPrincipalIds: [ | ||
weikanglim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{{- range .Services}} | ||
{{bicepName .Name}}Identity.outputs.principalId | ||
{{- end}} | ||
weikanglim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
principalId | ||
] | ||
sqlRoleDefinitions: [ | ||
{ | ||
name: 'service-access-cosmos-sql-role' | ||
} | ||
] | ||
capabilitiesToAdd: [ 'EnableServerless' ] | ||
} | ||
} | ||
{{- end}} | ||
|
||
{{- if .DbPostgres}} | ||
var databaseName = '{{ .DbPostgres.DatabaseName }}' | ||
var databaseUser = 'psqladmin' | ||
|
@@ -353,7 +405,7 @@ module {{bicepName .Name}} 'br/public:avm/res/app/container-app:0.8.0' = { | |
{ | ||
name: 'mongodb-url' | ||
identity:{{bicepName .Name}}Identity.outputs.resourceId | ||
keyVaultUrl: cosmos.outputs.exportedSecrets['MONGODB-URL'].secretUri | ||
keyVaultUrl: cosmosMongo.outputs.exportedSecrets['MONGODB-URL'].secretUri | ||
} | ||
{{- end}} | ||
{{- if .DbPostgres}} | ||
|
@@ -407,6 +459,12 @@ module {{bicepName .Name}} 'br/public:avm/res/app/container-app:0.8.0' = { | |
secretRef: 'mongodb-url' | ||
} | ||
{{- end}} | ||
{{- if .DbCosmos}} | ||
{ | ||
name: 'AZURE_COSMOS_ENDPOINT' | ||
value: cosmos.outputs.endpoint | ||
} | ||
{{- end}} | ||
{{- if .DbPostgres}} | ||
{ | ||
name: 'POSTGRES_HOST' | ||
|
@@ -606,6 +664,9 @@ output AZURE_RESOURCE_REDIS_ID string = redis.outputs.resourceId | |
{{- if .DbPostgres}} | ||
output AZURE_RESOURCE_{{alphaSnakeUpper .DbPostgres.DatabaseName}}_ID string = '${postgreServer.outputs.resourceId}/databases/{{.DbPostgres.DatabaseName}}' | ||
{{- end}} | ||
{{- if .DbCosmos }} | ||
output AZURE_RESOURCE_{{alphaSnakeUpper .DbCosmos.DatabaseName}}_ID string = cosmos.outputs.resourceId | ||
{{- end}} | ||
{{- if .StorageAccount }} | ||
output AZURE_RESOURCE_STORAGE_ID string = storageAccount.outputs.resourceId | ||
{{- end}} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the YAML schema, does
name
andpartitionKeys
feel nicer?