From 4d183717f816e759e2a44516f02f73a59077523a Mon Sep 17 00:00:00 2001 From: Jan-Henrik Damaschke Date: Wed, 6 Jul 2022 07:42:29 +0200 Subject: [PATCH 1/7] =?UTF-8?q?[Modules]=20Added=20CosmosDB=20Gremlin=20AP?= =?UTF-8?q?I=20and=20updated=20mongodb=20to=E2=80=A6=20(#1566)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(document-db): Added CosmosDB Gremlin API and updated mongodb to current version * docs(graphs): Updated readme.md * feat(document-db): Added backupPolicy, updated docs * Update arm/Microsoft.DocumentDB/databaseAccounts/deploy.bicep Co-authored-by: Alexander Sehr * feat(gremlin-databases): Added tests and small bugfixes * feat(gremlin): Updated tests, pipeline, parameters * refactor(test): Changed .parameters to .test Co-authored-by: Alexander Sehr --- .../ms.documentdb.databaseaccounts.yml | 1 + .../.test/gremlindb.parameters.json | 96 ++++++++++ .../mongodb.parameters.json | 0 .../plain.parameters.json | 0 .../sqldb.parameters.json | 0 .../databaseAccounts/deploy.bicep | 113 +++++++++-- .../gremlinDatabases/deploy.bicep | 94 +++++++++ .../gremlinDatabases/graphs/deploy.bicep | 66 +++++++ .../gremlinDatabases/graphs/readme.md | 118 ++++++++++++ .../gremlinDatabases/graphs/version.json | 4 + .../gremlinDatabases/readme.md | 178 ++++++++++++++++++ .../gremlinDatabases/version.json | 4 + .../databaseAccounts/readme.md | 80 +++++++- 13 files changed, 736 insertions(+), 18 deletions(-) create mode 100644 arm/Microsoft.DocumentDB/databaseAccounts/.test/gremlindb.parameters.json rename arm/Microsoft.DocumentDB/databaseAccounts/{.parameters => .test}/mongodb.parameters.json (100%) rename arm/Microsoft.DocumentDB/databaseAccounts/{.parameters => .test}/plain.parameters.json (100%) rename arm/Microsoft.DocumentDB/databaseAccounts/{.parameters => .test}/sqldb.parameters.json (100%) create mode 100644 arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep create mode 100644 arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/deploy.bicep create mode 100644 arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/readme.md create mode 100644 arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/version.json create mode 100644 arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md create mode 100644 arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/version.json diff --git a/.azuredevops/modulePipelines/ms.documentdb.databaseaccounts.yml b/.azuredevops/modulePipelines/ms.documentdb.databaseaccounts.yml index 4966965b0b..d7a849bdc1 100644 --- a/.azuredevops/modulePipelines/ms.documentdb.databaseaccounts.yml +++ b/.azuredevops/modulePipelines/ms.documentdb.databaseaccounts.yml @@ -46,6 +46,7 @@ stages: removeDeployment: '${{ parameters.removeDeployment }}' deploymentBlocks: - path: $(modulePath)/.parameters/mongodb.parameters.json + - path: $(modulePath)/.parameters/gremlindb.parameters.json - path: $(modulePath)/.parameters/plain.parameters.json - path: $(modulePath)/.parameters/sqldb.parameters.json diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/.test/gremlindb.parameters.json b/arm/Microsoft.DocumentDB/databaseAccounts/.test/gremlindb.parameters.json new file mode 100644 index 0000000000..e252a40107 --- /dev/null +++ b/arm/Microsoft.DocumentDB/databaseAccounts/.test/gremlindb.parameters.json @@ -0,0 +1,96 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "value": "<>-az-cdb-gremlindb-001" + }, + "location": { + "value": "West Europe" + }, + "locations": { + "value": [ + { + "locationName": "West Europe", + "failoverPriority": 0, + "isZoneRedundant": false + }, + { + "locationName": "North Europe", + "failoverPriority": 1, + "isZoneRedundant": false + } + ] + }, + "roleAssignments": { + "value": [ + { + "roleDefinitionIdOrName": "Reader", + "principalIds": [ + "<>" + ] + } + ] + }, + "gremlinDatabases": { + "value": [ + { + "name": "<>-az-gdb-x-001", + "graphs": [ + { + "name": "car_collection", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/car_id" + ] + }, + { + "name": "truck_collection", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/truck_id" + ] + } + ] + }, + { + "name": "<>-az-gdb-x-002", + "collections": [ + { + "name": "bike_collection", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/bike_id" + ] + }, + { + "name": "bicycle_collection", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/bicycle_id" + ] + } + ] + } + ] + }, + "diagnosticLogsRetentionInDays": { + "value": 7 + }, + "diagnosticStorageAccountId": { + "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001" + }, + "diagnosticWorkspaceId": { + "value": "/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001" + }, + "diagnosticEventHubAuthorizationRuleId": { + "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey" + }, + "diagnosticEventHubName": { + "value": "adp-<>-az-evh-x-001" + }, + "systemAssignedIdentity": { + "value": true + } + } +} diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/.parameters/mongodb.parameters.json b/arm/Microsoft.DocumentDB/databaseAccounts/.test/mongodb.parameters.json similarity index 100% rename from arm/Microsoft.DocumentDB/databaseAccounts/.parameters/mongodb.parameters.json rename to arm/Microsoft.DocumentDB/databaseAccounts/.test/mongodb.parameters.json diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/.parameters/plain.parameters.json b/arm/Microsoft.DocumentDB/databaseAccounts/.test/plain.parameters.json similarity index 100% rename from arm/Microsoft.DocumentDB/databaseAccounts/.parameters/plain.parameters.json rename to arm/Microsoft.DocumentDB/databaseAccounts/.test/plain.parameters.json diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/.parameters/sqldb.parameters.json b/arm/Microsoft.DocumentDB/databaseAccounts/.test/sqldb.parameters.json similarity index 100% rename from arm/Microsoft.DocumentDB/databaseAccounts/.parameters/sqldb.parameters.json rename to arm/Microsoft.DocumentDB/databaseAccounts/.test/sqldb.parameters.json diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/deploy.bicep b/arm/Microsoft.DocumentDB/databaseAccounts/deploy.bicep index 1f603356aa..23b36ad8f3 100644 --- a/arm/Microsoft.DocumentDB/databaseAccounts/deploy.bicep +++ b/arm/Microsoft.DocumentDB/databaseAccounts/deploy.bicep @@ -50,8 +50,9 @@ param maxIntervalInSeconds int = 300 '3.2' '3.6' '4.0' + '4.2' ]) -param serverVersion string = '4.0' +param serverVersion string = '4.2' @description('Optional. SQL Databases configurations.') param sqlDatabases array = [] @@ -59,6 +60,9 @@ param sqlDatabases array = [] @description('Optional. MongoDB Databases configurations.') param mongodbDatabases array = [] +@description('Optional. Gremlin Databases configurations.') +param gremlinDatabases array = [] + @description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).') param enableDefaultTelemetry bool = true @@ -125,6 +129,49 @@ param diagnosticMetricsToEnable array = [ @description('Optional. The name of the diagnostic setting, if deployed.') param diagnosticSettingsName string = '${name}-diagnosticSettings' +@allowed([ + 'EnableCassandra' + 'EnableTable' + 'EnableGremlin' + 'EnableMongo' + 'DisableRateLimitingResponses' + 'EnableServerless' +]) +@description('Optional. List of Cosmos DB capabilities for the account.') +param capabilitiesToAdd array = [] + +@allowed([ + 'Periodic' + 'Continuous' +]) +@description('Optional. Describes the mode of backups.') +param backupPolicyType string = 'Continuous' + +@allowed([ + 'Continuous30Days' + 'Continuous7Days' +]) +@description('Optional. Configuration values for continuous mode backup.') +param backupPolicyContinuousTier string = 'Continuous30Days' + +@minValue(60) +@maxValue(1440) +@description('Optional. An integer representing the interval in minutes between two backups. Only applies to periodic backup type.') +param backupIntervalInMinutes int = 240 + +@minValue(2) +@maxValue(720) +@description('Optional. An integer representing the time (in hours) that each backup is retained. Only applies to periodic backup type.') +param backupRetentionIntervalInHours int = 8 + +@allowed([ + 'Geo' + 'Local' + 'Zone' +]) +@description('Optional. Enum to indicate type of backup residency. Only applies to periodic backup type.') +param backupStorageRedundancy string = 'Local' + var diagnosticsLogs = [for category in diagnosticLogCategoriesToEnable: { category: category enabled: true @@ -177,25 +224,49 @@ var databaseAccount_locations = [for location in locations: { locationName: location.locationName }] -var kind = !empty(sqlDatabases) ? 'GlobalDocumentDB' : (!empty(mongodbDatabases) ? 'MongoDB' : 'Parse') +var kind = !empty(sqlDatabases) || !empty(gremlinDatabases) ? 'GlobalDocumentDB' : (!empty(mongodbDatabases) ? 'MongoDB' : 'Parse') var enableReferencedModulesTelemetry = false -var databaseAccount_properties = !empty(sqlDatabases) ? { - consistencyPolicy: consistencyPolicy[defaultConsistencyLevel] - locations: databaseAccount_locations - databaseAccountOfferType: databaseAccountOfferType - enableAutomaticFailover: automaticFailover -} : (!empty(mongodbDatabases) ? { - consistencyPolicy: consistencyPolicy[defaultConsistencyLevel] - locations: databaseAccount_locations - databaseAccountOfferType: databaseAccountOfferType - apiProperties: { - serverVersion: serverVersion +var capabilities = [for capability in capabilitiesToAdd: { + name: capability +}] + +var backupPolicy = backupPolicyType == 'Continuous' ? { + type: backupPolicyType + continuousModeProperties: { + tier: backupPolicyContinuousTier } } : { - databaseAccountOfferType: databaseAccountOfferType -}) + type: backupPolicyType + periodicModeProperties: { + backupIntervalInMinutes: backupIntervalInMinutes + backupRetentionIntervalInHours: backupRetentionIntervalInHours + backupStorageRedundancy: backupStorageRedundancy + } +} + +var databaseAccount_properties = union({ + databaseAccountOfferType: databaseAccountOfferType + }, + // Common properties + ((!empty(sqlDatabases) || !empty(mongodbDatabases) || !empty(gremlinDatabases)) ? { + consistencyPolicy: consistencyPolicy[defaultConsistencyLevel] + locations: databaseAccount_locations + capabilities: capabilities + backupPolicy: backupPolicy + } : {}), + // SQLDB properties + (!empty(sqlDatabases) ? { + enableAutomaticFailover: automaticFailover + } : {}), + // MongoDb properties + (!empty(mongodbDatabases) ? { + apiProperties: { + serverVersion: serverVersion + } + } : {}) +) resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) { name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name, location)}' @@ -209,7 +280,7 @@ resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (ena } } -resource databaseAccount 'Microsoft.DocumentDB/databaseAccounts@2021-06-15' = { +resource databaseAccount 'Microsoft.DocumentDB/databaseAccounts@2022-02-15-preview' = { name: name location: location tags: tags @@ -271,6 +342,16 @@ module mongodbDatabases_resource 'mongodbDatabases/deploy.bicep' = [for mongodbD } }] +module gremlinDatabases_resource 'gremlinDatabases/deploy.bicep' = [for gremlinDatabase in gremlinDatabases: { + name: '${uniqueString(deployment().name, location)}-gremlin-${gremlinDatabase.name}' + params: { + databaseAccountName: databaseAccount.name + name: gremlinDatabase.name + graphs: contains(gremlinDatabase, 'graphs') ? gremlinDatabase.graphs : [] + enableDefaultTelemetry: enableReferencedModulesTelemetry + } +}] + @description('The name of the database account.') output name string = databaseAccount.name diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep new file mode 100644 index 0000000000..ebaef62e11 --- /dev/null +++ b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep @@ -0,0 +1,94 @@ +@description('Required. Name of the Gremlin database.') +param name string + +@description('Optional. Tags of the Gremlin database resource.') +param tags object = {} + +@description('Optional. Enables system assigned managed identity on the resource.') +param systemAssignedIdentity bool = false + +@description('Optional. The ID(s) to assign to the resource.') +param userAssignedIdentities object = {} + +@description('Conditional. The name of the parent Gremlin database. Required if the template is used in a standalone deployment.') +param databaseAccountName string + +@description('Optional. Array of graphs to deploy in the Gremlin database.') +param graphs array = [] + +@minValue(400) +@description('Optional. Represents maximum throughput, the resource can scale up to.') +param maxThroughput int = 0 + +@minValue(400) +@description('Optional. Request Units per second. For example, "throughput": 10000.') +param throughput int = 0 + +@description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).') +param enableDefaultTelemetry bool = false + +var enableReferencedModulesTelemetry = false + +var identityType = systemAssignedIdentity ? (!empty(userAssignedIdentities) ? 'SystemAssigned, UserAssigned' : 'SystemAssigned') : (!empty(userAssignedIdentities) ? 'UserAssigned' : 'None') + +var identity = identityType != 'None' ? { + type: identityType + userAssignedIdentities: !empty(userAssignedIdentities) ? userAssignedIdentities : null +} : null + +resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) { + name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name)}' + properties: { + mode: 'Incremental' + template: { + '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#' + contentVersion: '1.0.0.0' + resources: [] + } + } +} + +resource databaseAccount 'Microsoft.DocumentDB/databaseAccounts@2022-02-15-preview' existing = { + name: databaseAccountName +} + +var databaseOptions = contains(databaseAccount.properties.capabilities, { name: 'EnableServerless' }) ? {} : { + autoscaleSettings: { + maxThroughput: maxThroughput + } + throughput: throughput +} + +resource gremlinDatabase 'Microsoft.DocumentDB/databaseAccounts/gremlinDatabases@2022-02-15-preview' = { + name: name + tags: tags + parent: databaseAccount + identity: identity + properties: { + options: databaseOptions + resource: { + id: name + } + } +} + +module gremlinGraphs 'graphs/deploy.bicep' = [for graph in graphs: { + name: '${uniqueString(deployment().name, gremlinDatabase.name)}-gremlindb-${graph.name}' + params: { + name: graph.name + gremlinDatabaseName: name + databaseAccountName: databaseAccountName + enableDefaultTelemetry: enableReferencedModulesTelemetry + automaticIndexing: contains(graph, 'automaticIndexing') ? graph.automaticIndexing : true + partitionKeyPaths: !empty(graph.partitionKeyPaths) ? graph.partitionKeyPaths : [] + } +}] + +@description('The name of the Gremlin database.') +output name string = gremlinDatabase.name + +@description('The resource ID of the Gremlin database.') +output resourceId string = gremlinDatabase.id + +@description('The name of the resource group the Gremlin database was created in.') +output resourceGroupName string = resourceGroup().name diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/deploy.bicep b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/deploy.bicep new file mode 100644 index 0000000000..59742e7da2 --- /dev/null +++ b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/deploy.bicep @@ -0,0 +1,66 @@ +@description('Required. Name of the graph.') +param name string + +@description('Optional. Tags of the Gremlin graph resource.') +param tags object = {} + +@description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).') +param enableDefaultTelemetry bool = true + +@description('Conditional. The name of the parent Database Account. Required if the template is used in a standalone deployment.') +param databaseAccountName string + +@description('Conditional. The name of the parent Gremlin Database. Required if the template is used in a standalone deployment.') +param gremlinDatabaseName string + +@description('Optional. Indicates if the indexing policy is automatic.') +param automaticIndexing bool = true + +@description('Optional. List of paths using which data within the container can be partitioned.') +param partitionKeyPaths array = [] + +resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) { + name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name)}' + properties: { + mode: 'Incremental' + template: { + '$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#' + contentVersion: '1.0.0.0' + resources: [] + } + } +} + +resource databaseAccount 'Microsoft.DocumentDB/databaseAccounts@2022-02-15-preview' existing = { + name: databaseAccountName + + resource gremlinDatabase 'gremlinDatabases@2022-02-15-preview' existing = { + name: gremlinDatabaseName + } +} + +resource gremlinGraph 'Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs@2022-02-15-preview' = { + name: name + tags: tags + parent: databaseAccount::gremlinDatabase + properties: { + resource: { + id: name + indexingPolicy: { + automatic: automaticIndexing + } + partitionKey: { + paths: !empty(partitionKeyPaths) ? partitionKeyPaths : null + } + } + } +} + +@description('The name of the graph.') +output name string = gremlinGraph.name + +@description('The resource ID of the graph.') +output resourceId string = gremlinGraph.id + +@description('The name of the resource group the graph was created in.') +output resourceGroupName string = resourceGroup().name diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/readme.md b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/readme.md new file mode 100644 index 0000000000..a03f7cb937 --- /dev/null +++ b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/readme.md @@ -0,0 +1,118 @@ +# DocumentDB DatabaseAccounts GremlinDatabases Graphs `[Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs]` + +This module deploys DocumentDB DatabaseAccounts GremlinDatabases Graphs. + +## Navigation + +- [Resource Types](#Resource-Types) +- [Parameters](#Parameters) +- [Outputs](#Outputs) + +## Resource Types + +| Resource Type | API Version | +| :-- | :-- | +| `Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs` | [2022-02-15-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2022-02-15-preview/databaseAccounts/gremlinDatabases/graphs) | + +## Parameters + +**Required parameters** +| Parameter Name | Type | Description | +| :-- | :-- | :-- | +| `name` | string | Name of the graph. | + +**Conditional parameters** +| Parameter Name | Type | Description | +| :-- | :-- | :-- | +| `databaseAccountName` | string | The name of the parent Database Account. Required if the template is used in a standalone deployment. | +| `gremlinDatabaseName` | string | The name of the parent Gremlin Database. Required if the template is used in a standalone deployment. | + +**Optional parameters** +| Parameter Name | Type | Default Value | Allowed Values | Description | +| :-- | :-- | :-- | :-- | :-- | +| `automaticIndexing` | bool | `True` | | Indicates if the indexing policy is automatic. | +| `enableDefaultTelemetry` | bool | `False` | | Enable telemetry via the Customer Usage Attribution ID (GUID). | +| `kind` | string | `'Hash'` | `[Hash, MultiHash, Range]` | Indicates the kind of algorithm used for partitioning. For MultiHash, multiple partition keys (up to three maximum) are supported for container create. | +| `partitionKeyPaths` | array | `[]` | | List of paths using which data within the container can be partitioned. | +| `tags` | object | `{object}` | | Tags of the Gremlin graph resource. | + + +### Parameter Usage: `tags` + +Tag names and tag values can be provided as needed. A tag can be left without a value. + +
+ +Parameter JSON format + +```json +"tags": { + "value": { + "Environment": "Non-Prod", + "Contact": "test.user@testcompany.com", + "PurchaseOrder": "1234", + "CostCenter": "7890", + "ServiceName": "DeploymentValidation", + "Role": "DeploymentValidation" + } +} +``` + +
+ +
+ +Bicep format + +```bicep +tags: { + Environment: 'Non-Prod' + Contact: 'test.user@testcompany.com' + PurchaseOrder: '1234' + CostCenter: '7890' + ServiceName: 'DeploymentValidation' + Role: 'DeploymentValidation' +} +``` + +
+

+ +### Parameter Usage: `partitionKeyPaths`, `uniqueKeyPaths` + +Different kinds of paths can be provided as array of strings: + +

+ +Bicep format + +```bicep +graphs: [ + { + name: 'graph01' + automaticIndexing: true + partitionKeyPaths: [ + '/name' + ], + + } + { + name: 'graph02' + automaticIndexing: true + partitionKeyPaths: [ + '/address' + ] + } +] +``` + +
+

+ +## Outputs + +| Output Name | Type | Description | +| :-- | :-- | :-- | +| `name` | string | The name of the graph. | +| `resourceGroupName` | string | The name of the resource group the graph was created in. | +| `resourceId` | string | The resource ID of the graph. | diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/version.json b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/version.json new file mode 100644 index 0000000000..56f8d9ca40 --- /dev/null +++ b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/version.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "0.4" +} diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md new file mode 100644 index 0000000000..0e980359e0 --- /dev/null +++ b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md @@ -0,0 +1,178 @@ +# DocumentDB DatabaseAccounts GremlinDatabases `[Microsoft.DocumentDB/databaseAccounts/gremlinDatabases]` + +This module deploys a GremlinDB within a CosmosDB account. + +## Navigation + +- [Resource Types](#Resource-Types) +- [Parameters](#Parameters) +- [Outputs](#Outputs) + +## Resource Types + +| Resource Type | API Version | +| :-- | :-- | +| `Microsoft.DocumentDB/databaseAccounts/gremlinDatabases` | [2022-02-15-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2022-02-15-preview/databaseAccounts/gremlinDatabases) | +| `Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs` | [2022-02-15-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2022-02-15-preview/databaseAccounts/gremlinDatabases/graphs) | + +## Parameters + +**Required parameters** +| Parameter Name | Type | Description | +| :-- | :-- | :-- | +| `name` | string | Name of the Gremlin database. | + +**Conditional parameters** +| Parameter Name | Type | Description | +| :-- | :-- | :-- | +| `databaseAccountName` | string | The name of the parent Gremlin database. Required if the template is used in a standalone deployment. | + +**Optional parameters** +| Parameter Name | Type | Default Value | Description | +| :-- | :-- | :-- | :-- | +| `enableDefaultTelemetry` | bool | `False` | Enable telemetry via the Customer Usage Attribution ID (GUID). | +| `graphs` | _[graphs](graphs/readme.md)_ array | `[]` | Array of graphs to deploy in the SQL database. | +| `maxThroughput` | int | `0` | Represents maximum throughput, the resource can scale up to. | +| `systemAssignedIdentity` | bool | `False` | Enables system assigned managed identity on the resource. | +| `tags` | object | `{object}` | Tags of the Gremlin database resource. | +| `throughput` | int | `0` | Request Units per second. For example, "throughput": 10000. | +| `userAssignedIdentities` | object | `{object}` | The ID(s) to assign to the resource. | + + +### Parameter Usage: `graphs` + +List of graph databaseAccounts + +

+ +Parameter JSON format + +```json +"graphs": { + "value": [ + { + "name": "graph01", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/name" + ] + }, + { + "name": "graph02", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/name" + ] + } + ] +} +``` + +
+ +
+ +Bicep format + +```bicep +graphs: [ + { + name: 'graph01' + automaticIndexing: true + partitionKeyPaths: [ + '/name' + ] + } + { + name: 'graph02' + automaticIndexing: true + partitionKeyPaths: [ + '/name' + ] + } +] +``` + +
+ +### Parameter Usage: `tags` + +Tag names and tag values can be provided as needed. A tag can be left without a value. + +
+ +Parameter JSON format + +```json +"tags": { + "value": { + "Environment": "Non-Prod", + "Contact": "test.user@testcompany.com", + "PurchaseOrder": "1234", + "CostCenter": "7890", + "ServiceName": "DeploymentValidation", + "Role": "DeploymentValidation" + } +} +``` + +
+ +
+ +Bicep format + +```bicep +tags: { + Environment: 'Non-Prod' + Contact: 'test.user@testcompany.com' + PurchaseOrder: '1234' + CostCenter: '7890' + ServiceName: 'DeploymentValidation' + Role: 'DeploymentValidation' +} +``` + +
+

+ +### Parameter Usage: `userAssignedIdentities` + +You can specify multiple user assigned identities to a resource by providing additional resource IDs using the following format: + +

+ +Parameter JSON format + +```json +"userAssignedIdentities": { + "value": { + "/subscriptions/12345678-1234-1234-1234-123456789012/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001": {}, + "/subscriptions/12345678-1234-1234-1234-123456789012/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002": {} + } +} +``` + +
+ +
+ +Bicep format + +```bicep +userAssignedIdentities: { + '/subscriptions/12345678-1234-1234-1234-123456789012/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-001': {} + '/subscriptions/12345678-1234-1234-1234-123456789012/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-sxx-az-msi-x-002': {} +} +``` + +
+

+ +## Outputs + +| Output Name | Type | Description | +| :-- | :-- | :-- | +| `name` | string | The name of the Gremlin database. | +| `resourceGroupName` | string | The name of the resource group the Gremlin database was created in. | +| `resourceId` | string | The resource ID of the Gremlin database. | diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/version.json b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/version.json new file mode 100644 index 0000000000..56f8d9ca40 --- /dev/null +++ b/arm/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/version.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json", + "version": "0.4" +} diff --git a/arm/Microsoft.DocumentDB/databaseAccounts/readme.md b/arm/Microsoft.DocumentDB/databaseAccounts/readme.md index 5330eb80d5..5765243238 100644 --- a/arm/Microsoft.DocumentDB/databaseAccounts/readme.md +++ b/arm/Microsoft.DocumentDB/databaseAccounts/readme.md @@ -15,7 +15,9 @@ This module deploys a DocumentDB database account and its child resources. | :-- | :-- | | `Microsoft.Authorization/locks` | [2017-04-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2017-04-01/locks) | | `Microsoft.Authorization/roleAssignments` | [2020-10-01-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Authorization/2020-10-01-preview/roleAssignments) | -| `Microsoft.DocumentDB/databaseAccounts` | [2021-06-15](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2021-06-15/databaseAccounts) | +| `Microsoft.DocumentDB/databaseAccounts` | [2022-02-15-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2022-02-15-preview/databaseAccounts) | +| `Microsoft.DocumentDB/databaseAccounts/gremlinDatabases` | [2022-02-15-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2022-02-15-preview/databaseAccounts/gremlinDatabases) | +| `Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs` | [2022-02-15-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2022-02-15-preview/databaseAccounts/gremlinDatabases/graphs) | | `Microsoft.DocumentDB/databaseAccounts/mongodbDatabases` | [2021-07-01-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2021-07-01-preview/databaseAccounts/mongodbDatabases) | | `Microsoft.DocumentDB/databaseAccounts/mongodbDatabases/collections` | [2021-07-01-preview](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2021-07-01-preview/databaseAccounts/mongodbDatabases/collections) | | `Microsoft.DocumentDB/databaseAccounts/sqlDatabases` | [2021-06-15](https://docs.microsoft.com/en-us/azure/templates/Microsoft.DocumentDB/2021-06-15/databaseAccounts/sqlDatabases) | @@ -34,6 +36,12 @@ This module deploys a DocumentDB database account and its child resources. | Parameter Name | Type | Default Value | Allowed Values | Description | | :-- | :-- | :-- | :-- | :-- | | `automaticFailover` | bool | `True` | | Enable automatic failover for regions. | +| `backupIntervalInMinutes` | int | `240` | | An integer representing the interval in minutes between two backups. Only applies to periodic backup type. | +| `backupPolicyContinuousTier` | string | `'Continuous30Days'` | `[Continuous30Days, Continuous7Days]` | Configuration values for continuous mode backup. | +| `backupPolicyType` | string | `'Continuous'` | `[Periodic, Continuous]` | Describes the mode of backups. | +| `backupRetentionIntervalInHours` | int | `8` | | An integer representing the time (in hours) that each backup is retained. Only applies to periodic backup type. | +| `backupStorageRedundancy` | string | `'Local'` | `[Geo, Local, Zone]` | Enum to indicate type of backup residency. Only applies to periodic backup type. | +| `capabilitiesToAdd` | array | `[]` | `[EnableCassandra, EnableTable, EnableGremlin, EnableMongo, DisableRateLimitingResponses, EnableServerless]` | List of Cosmos DB capabilities for the account. | | `databaseAccountOfferType` | string | `'Standard'` | `[Standard]` | The offer type for the Cosmos DB database account. | | `defaultConsistencyLevel` | string | `'Session'` | `[Eventual, ConsistentPrefix, Session, BoundedStaleness, Strong]` | The default consistency level of the Cosmos DB account. | | `diagnosticEventHubAuthorizationRuleId` | string | `''` | | Resource ID of the diagnostic event hub authorization rule for the Event Hubs namespace in which the event hub should be created or streamed to. | @@ -45,13 +53,14 @@ This module deploys a DocumentDB database account and its child resources. | `diagnosticStorageAccountId` | string | `''` | | Resource ID of the diagnostic storage account. | | `diagnosticWorkspaceId` | string | `''` | | Resource ID of the log analytics workspace. | | `enableDefaultTelemetry` | bool | `True` | | Enable telemetry via the Customer Usage Attribution ID (GUID). | +| `gremlinDatabases` | _[gremlinDatabases](gremlinDatabases/readme.md)_ array | `[]` | | Gremlin Databases configurations. | | `location` | string | `[resourceGroup().location]` | | Location for all resources. | | `lock` | string | `''` | `[, CanNotDelete, ReadOnly]` | Specify the type of lock. | | `maxIntervalInSeconds` | int | `300` | | Max lag time (minutes). Required for BoundedStaleness. Valid ranges, Single Region: 5 to 84600. Multi Region: 300 to 86400. | | `maxStalenessPrefix` | int | `100000` | | Max stale requests. Required for BoundedStaleness. Valid ranges, Single Region: 10 to 1000000. Multi Region: 100000 to 1000000. | | `mongodbDatabases` | _[mongodbDatabases](mongodbDatabases/readme.md)_ array | `[]` | | MongoDB Databases configurations. | | `roleAssignments` | array | `[]` | | Array of role assignment objects that contain the 'roleDefinitionIdOrName' and 'principalIds' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: '/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11'. | -| `serverVersion` | string | `'4.0'` | `[3.2, 3.6, 4.0]` | Specifies the MongoDB server version to use. | +| `serverVersion` | string | `'4.2'` | `[3.2, 3.6, 4.0, 4.2]` | Specifies the MongoDB server version to use. | | `sqlDatabases` | _[sqlDatabases](sqlDatabases/readme.md)_ array | `[]` | | SQL Databases configurations. | | `systemAssignedIdentity` | bool | `False` | | Enables system assigned managed identity on the resource. | | `tags` | object | `{object}` | | Tags of the Database Account resource. | @@ -299,6 +308,73 @@ mongodbDatabases: [ Please reference the documentation for [mongodbDatabases](./mongodbDatabases/readme.md) +### Parameter Usage: `gremlinDatabases` + +

+ +Parameter JSON format + +```json +"mongodbDatabases": { + "value": [ + { + "name": "graphDb01", + "graphs": [ + { + "name": "graph01", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/name" + ] + }, + { + "name": "graph02", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/name" + ] + } + ] + } + ] +} +``` + +
+ +
+ +Bicep format + +```bicep +gremlinDatabases: [ + { + name: 'graphDb01' + graphs: [ + { + name: 'graph01' + automaticIndexing: true + partitionKeyPaths: [ + '/name' + ] + } + { + name: 'graph02' + automaticIndexing: true + partitionKeyPaths: [ + '/name' + ] + } + ] + } +] +``` + +
+

+ +Please reference the documentation for [gremlinDatabases](./gremlinDatabases/readme.md) + ### Parameter Usage: `roleAssignments` Create a role assignment for the given resource. If you want to assign a service principal / managed identity that is created in the same deployment, make sure to also specify the `'principalType'` parameter and set it to 'ServicePrincipal'. This will ensure the role assignment waits for the principal's propagation in Azure. From 4e70de5df4b473f2fdd5933be957f74f4232b9fe Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 6 Jul 2022 07:52:51 +0200 Subject: [PATCH 2/7] Minor updates --- .../Microsoft.DocumentDB/databaseAccounts/deploy.bicep | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/deploy.bicep b/modules/Microsoft.DocumentDB/databaseAccounts/deploy.bicep index 23b36ad8f3..7760a05421 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/deploy.bicep +++ b/modules/Microsoft.DocumentDB/databaseAccounts/deploy.bicep @@ -311,7 +311,7 @@ resource databaseAccount_diagnosticSettings 'Microsoft.Insights/diagnosticsettin scope: databaseAccount } -module databaseAccount_rbac '.bicep/nested_roleAssignments.bicep' = [for (roleAssignment, index) in roleAssignments: { +module databaseAccount_roleAssignments '.bicep/nested_roleAssignments.bicep' = [for (roleAssignment, index) in roleAssignments: { name: '${uniqueString(deployment().name, location)}-Rbac-${index}' params: { description: contains(roleAssignment, 'description') ? roleAssignment.description : '' @@ -322,7 +322,7 @@ module databaseAccount_rbac '.bicep/nested_roleAssignments.bicep' = [for (roleAs } }] -module sqlDatabases_resource 'sqlDatabases/deploy.bicep' = [for sqlDatabase in sqlDatabases: { +module databaseAccount_sqlDatabases 'sqlDatabases/deploy.bicep' = [for sqlDatabase in sqlDatabases: { name: '${uniqueString(deployment().name, location)}-sqldb-${sqlDatabase.name}' params: { databaseAccountName: databaseAccount.name @@ -332,7 +332,7 @@ module sqlDatabases_resource 'sqlDatabases/deploy.bicep' = [for sqlDatabase in s } }] -module mongodbDatabases_resource 'mongodbDatabases/deploy.bicep' = [for mongodbDatabase in mongodbDatabases: { +module databaseAccount_mongodbDatabases 'mongodbDatabases/deploy.bicep' = [for mongodbDatabase in mongodbDatabases: { name: '${uniqueString(deployment().name, location)}-mongodb-${mongodbDatabase.name}' params: { databaseAccountName: databaseAccount.name @@ -342,7 +342,7 @@ module mongodbDatabases_resource 'mongodbDatabases/deploy.bicep' = [for mongodbD } }] -module gremlinDatabases_resource 'gremlinDatabases/deploy.bicep' = [for gremlinDatabase in gremlinDatabases: { +module databaseAccount_gremlinDatabases 'gremlinDatabases/deploy.bicep' = [for gremlinDatabase in gremlinDatabases: { name: '${uniqueString(deployment().name, location)}-gremlin-${gremlinDatabase.name}' params: { databaseAccountName: databaseAccount.name From 3b5f164ba44d9e0ca665322cf163a9cd9bf36e5f Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 6 Jul 2022 07:53:58 +0200 Subject: [PATCH 3/7] Adjusted telemetry --- .../databaseAccounts/gremlinDatabases/deploy.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep index ebaef62e11..0a34077b83 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep +++ b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep @@ -25,7 +25,7 @@ param maxThroughput int = 0 param throughput int = 0 @description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).') -param enableDefaultTelemetry bool = false +param enableDefaultTelemetry bool = true var enableReferencedModulesTelemetry = false From 66752f5dc63ebb4bf9c7b2b44c576dd3b31da005 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 6 Jul 2022 07:55:25 +0200 Subject: [PATCH 4/7] Additional small updates --- .../databaseAccounts/gremlinDatabases/deploy.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep index 0a34077b83..9e7d933911 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep +++ b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep @@ -72,7 +72,7 @@ resource gremlinDatabase 'Microsoft.DocumentDB/databaseAccounts/gremlinDatabases } } -module gremlinGraphs 'graphs/deploy.bicep' = [for graph in graphs: { +module gremlinDatabase_gremlinGraphs 'graphs/deploy.bicep' = [for graph in graphs: { name: '${uniqueString(deployment().name, gremlinDatabase.name)}-gremlindb-${graph.name}' params: { name: graph.name From e9d4fa3441d5c3f64d7d1da83bb1120d41826859 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 6 Jul 2022 07:59:11 +0200 Subject: [PATCH 5/7] Updated docs --- .../gremlinDatabases/graphs/readme.md | 13 +- .../gremlinDatabases/readme.md | 4 +- .../databaseAccounts/readme.md | 197 +++++++++++++++++- 3 files changed, 200 insertions(+), 14 deletions(-) diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/readme.md b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/readme.md index 63b9be94b4..f53dc851b6 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/readme.md +++ b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/graphs/readme.md @@ -28,13 +28,12 @@ This module deploys DocumentDB DatabaseAccounts GremlinDatabases Graphs. | `gremlinDatabaseName` | string | The name of the parent Gremlin Database. Required if the template is used in a standalone deployment. | **Optional parameters** -| Parameter Name | Type | Default Value | Allowed Values | Description | -| :-- | :-- | :-- | :-- | :-- | -| `automaticIndexing` | bool | `True` | | Indicates if the indexing policy is automatic. | -| `enableDefaultTelemetry` | bool | `False` | | Enable telemetry via the Customer Usage Attribution ID (GUID). | -| `kind` | string | `'Hash'` | `[Hash, MultiHash, Range]` | Indicates the kind of algorithm used for partitioning. For MultiHash, multiple partition keys (up to three maximum) are supported for container create. | -| `partitionKeyPaths` | array | `[]` | | List of paths using which data within the container can be partitioned. | -| `tags` | object | `{object}` | | Tags of the Gremlin graph resource. | +| Parameter Name | Type | Default Value | Description | +| :-- | :-- | :-- | :-- | +| `automaticIndexing` | bool | `True` | Indicates if the indexing policy is automatic. | +| `enableDefaultTelemetry` | bool | `True` | Enable telemetry via the Customer Usage Attribution ID (GUID). | +| `partitionKeyPaths` | array | `[]` | List of paths using which data within the container can be partitioned. | +| `tags` | object | `{object}` | Tags of the Gremlin graph resource. | ### Parameter Usage: `tags` diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md index df53c9827e..2684bce83a 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md +++ b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md @@ -30,8 +30,8 @@ This module deploys a GremlinDB within a CosmosDB account. **Optional parameters** | Parameter Name | Type | Default Value | Description | | :-- | :-- | :-- | :-- | -| `enableDefaultTelemetry` | bool | `False` | Enable telemetry via the Customer Usage Attribution ID (GUID). | -| `graphs` | _[graphs](graphs/readme.md)_ array | `[]` | Array of graphs to deploy in the SQL database. | +| `enableDefaultTelemetry` | bool | `True` | Enable telemetry via the Customer Usage Attribution ID (GUID). | +| `graphs` | _[graphs](graphs/readme.md)_ array | `[]` | Array of graphs to deploy in the Gremlin database. | | `maxThroughput` | int | `0` | Represents maximum throughput, the resource can scale up to. | | `systemAssignedIdentity` | bool | `False` | Enables system assigned managed identity on the resource. | | `tags` | object | `{object}` | Tags of the Gremlin database resource. | diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/readme.md b/modules/Microsoft.DocumentDB/databaseAccounts/readme.md index 5765243238..c25ce65b13 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/readme.md +++ b/modules/Microsoft.DocumentDB/databaseAccounts/readme.md @@ -538,6 +538,196 @@ userAssignedIdentities: {

via JSON Parameter file +```json +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "value": "<>-az-cdb-gremlindb-001" + }, + "location": { + "value": "West Europe" + }, + "locations": { + "value": [ + { + "locationName": "West Europe", + "failoverPriority": 0, + "isZoneRedundant": false + }, + { + "locationName": "North Europe", + "failoverPriority": 1, + "isZoneRedundant": false + } + ] + }, + "roleAssignments": { + "value": [ + { + "roleDefinitionIdOrName": "Reader", + "principalIds": [ + "<>" + ] + } + ] + }, + "gremlinDatabases": { + "value": [ + { + "name": "<>-az-gdb-x-001", + "graphs": [ + { + "name": "car_collection", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/car_id" + ] + }, + { + "name": "truck_collection", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/truck_id" + ] + } + ] + }, + { + "name": "<>-az-gdb-x-002", + "collections": [ + { + "name": "bike_collection", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/bike_id" + ] + }, + { + "name": "bicycle_collection", + "automaticIndexing": true, + "partitionKeyPaths": [ + "/bicycle_id" + ] + } + ] + } + ] + }, + "diagnosticLogsRetentionInDays": { + "value": 7 + }, + "diagnosticStorageAccountId": { + "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001" + }, + "diagnosticWorkspaceId": { + "value": "/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001" + }, + "diagnosticEventHubAuthorizationRuleId": { + "value": "/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey" + }, + "diagnosticEventHubName": { + "value": "adp-<>-az-evh-x-001" + }, + "systemAssignedIdentity": { + "value": true + } + } +} +``` + + + +
+ +via Bicep module + +```bicep +module databaseAccounts './Microsoft.DocumentDB/databaseAccounts/deploy.bicep' = { + name: '${uniqueString(deployment().name)}-databaseAccounts' + params: { + name: '<>-az-cdb-gremlindb-001' + location: 'West Europe' + locations: [ + { + locationName: 'West Europe' + failoverPriority: 0 + isZoneRedundant: false + } + { + locationName: 'North Europe' + failoverPriority: 1 + isZoneRedundant: false + } + ] + roleAssignments: [ + { + roleDefinitionIdOrName: 'Reader' + principalIds: [ + '<>' + ] + } + ] + gremlinDatabases: [ + { + name: '<>-az-gdb-x-001' + graphs: [ + { + name: 'car_collection' + automaticIndexing: true + partitionKeyPaths: [ + '/car_id' + ] + } + { + name: 'truck_collection' + automaticIndexing: true + partitionKeyPaths: [ + '/truck_id' + ] + } + ] + } + { + name: '<>-az-gdb-x-002' + collections: [ + { + name: 'bike_collection' + automaticIndexing: true + partitionKeyPaths: [ + '/bike_id' + ] + } + { + name: 'bicycle_collection' + automaticIndexing: true + partitionKeyPaths: [ + '/bicycle_id' + ] + } + ] + } + ] + diagnosticLogsRetentionInDays: 7 + diagnosticStorageAccountId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.Storage/storageAccounts/adp<>azsax001' + diagnosticWorkspaceId: '/subscriptions/<>/resourcegroups/validation-rg/providers/microsoft.operationalinsights/workspaces/adp-<>-az-law-x-001' + diagnosticEventHubAuthorizationRuleId: '/subscriptions/<>/resourceGroups/validation-rg/providers/Microsoft.EventHub/namespaces/adp-<>-az-evhns-x-001/AuthorizationRules/RootManageSharedAccessKey' + diagnosticEventHubName: 'adp-<>-az-evh-x-001' + systemAssignedIdentity: true + } +} +``` + +
+

+ +

Example 2

+ +
+ +via JSON Parameter file + ```json { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", @@ -779,7 +969,6 @@ userAssignedIdentities: { } } } - ```
@@ -1011,7 +1200,7 @@ module databaseAccounts './Microsoft.DocumentDB/databaseAccounts/deploy.bicep' =

-

Example 2

+

Example 3

@@ -1069,7 +1258,6 @@ module databaseAccounts './Microsoft.DocumentDB/databaseAccounts/deploy.bicep' = } } } - ```
@@ -1116,7 +1304,7 @@ module databaseAccounts './Microsoft.DocumentDB/databaseAccounts/deploy.bicep' =

-

Example 3

+

Example 4

@@ -1199,7 +1387,6 @@ module databaseAccounts './Microsoft.DocumentDB/databaseAccounts/deploy.bicep' = } } } - ```
From bc242f8380bd698c13737dbf3e392eb67cca1e7c Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 6 Jul 2022 08:33:11 +0200 Subject: [PATCH 6/7] Applied several fixes --- .../databaseAccounts/deploy.bicep | 18 +++++++----------- .../gremlinDatabases/deploy.bicep | 4 +--- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/deploy.bicep b/modules/Microsoft.DocumentDB/databaseAccounts/deploy.bicep index 7760a05421..5361d5c066 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/deploy.bicep +++ b/modules/Microsoft.DocumentDB/databaseAccounts/deploy.bicep @@ -248,25 +248,21 @@ var backupPolicy = backupPolicyType == 'Continuous' ? { var databaseAccount_properties = union({ databaseAccountOfferType: databaseAccountOfferType - }, - // Common properties - ((!empty(sqlDatabases) || !empty(mongodbDatabases) || !empty(gremlinDatabases)) ? { + }, ((!empty(sqlDatabases) || !empty(mongodbDatabases) || !empty(gremlinDatabases)) ? { + // Common properties consistencyPolicy: consistencyPolicy[defaultConsistencyLevel] locations: databaseAccount_locations capabilities: capabilities backupPolicy: backupPolicy - } : {}), - // SQLDB properties - (!empty(sqlDatabases) ? { + } : {}), (!empty(sqlDatabases) ? { + // SQLDB properties enableAutomaticFailover: automaticFailover - } : {}), - // MongoDb properties - (!empty(mongodbDatabases) ? { + } : {}), (!empty(mongodbDatabases) ? { + // MongoDb properties apiProperties: { serverVersion: serverVersion } - } : {}) -) + } : {})) resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) { name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name, location)}' diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep index 9e7d933911..bb3576ed47 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep +++ b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep @@ -16,11 +16,9 @@ param databaseAccountName string @description('Optional. Array of graphs to deploy in the Gremlin database.') param graphs array = [] -@minValue(400) @description('Optional. Represents maximum throughput, the resource can scale up to.') param maxThroughput int = 0 -@minValue(400) @description('Optional. Request Units per second. For example, "throughput": 10000.') param throughput int = 0 @@ -52,7 +50,7 @@ resource databaseAccount 'Microsoft.DocumentDB/databaseAccounts@2022-02-15-previ name: databaseAccountName } -var databaseOptions = contains(databaseAccount.properties.capabilities, { name: 'EnableServerless' }) ? {} : { +var databaseOptions = contains(databaseAccount.properties.capabilities, 'EnableServerless') ? {} : { autoscaleSettings: { maxThroughput: maxThroughput } From 896a3e44088e836bb8fad5247c9add1da2ecb460 Mon Sep 17 00:00:00 2001 From: MrMCake Date: Wed, 6 Jul 2022 14:12:03 +0200 Subject: [PATCH 7/7] Updated throughput logic --- .../.test/gremlindb.parameters.json | 5 +++++ .../databaseAccounts/gremlinDatabases/deploy.bicep | 14 +++++++------- .../databaseAccounts/gremlinDatabases/readme.md | 4 ++-- .../databaseAccounts/readme.md | 8 ++++++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/.test/gremlindb.parameters.json b/modules/Microsoft.DocumentDB/databaseAccounts/.test/gremlindb.parameters.json index e252a40107..ec025620b5 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/.test/gremlindb.parameters.json +++ b/modules/Microsoft.DocumentDB/databaseAccounts/.test/gremlindb.parameters.json @@ -22,6 +22,11 @@ } ] }, + "capabilitiesToAdd": { + "value": [ + "EnableGremlin" + ] + }, "roleAssignments": { "value": [ { diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep index bb3576ed47..956bb758f5 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep +++ b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/deploy.bicep @@ -16,11 +16,11 @@ param databaseAccountName string @description('Optional. Array of graphs to deploy in the Gremlin database.') param graphs array = [] -@description('Optional. Represents maximum throughput, the resource can scale up to.') -param maxThroughput int = 0 +@description('Optional. Represents maximum throughput, the resource can scale up to. Cannot be set together with `throughput`. If `throughput` is set to something else than -1, this autoscale setting is ignored.') +param maxThroughput int = 4000 -@description('Optional. Request Units per second. For example, "throughput": 10000.') -param throughput int = 0 +@description('Optional. Request Units per second (for example 10000). Cannot be set together with `maxThroughput`.') +param throughput int = -1 @description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).') param enableDefaultTelemetry bool = true @@ -51,10 +51,10 @@ resource databaseAccount 'Microsoft.DocumentDB/databaseAccounts@2022-02-15-previ } var databaseOptions = contains(databaseAccount.properties.capabilities, 'EnableServerless') ? {} : { - autoscaleSettings: { + autoscaleSettings: throughput == -1 ? { maxThroughput: maxThroughput - } - throughput: throughput + } : null + throughput: throughput != -1 ? throughput : null } resource gremlinDatabase 'Microsoft.DocumentDB/databaseAccounts/gremlinDatabases@2022-02-15-preview' = { diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md index 2684bce83a..4563137d8d 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md +++ b/modules/Microsoft.DocumentDB/databaseAccounts/gremlinDatabases/readme.md @@ -32,10 +32,10 @@ This module deploys a GremlinDB within a CosmosDB account. | :-- | :-- | :-- | :-- | | `enableDefaultTelemetry` | bool | `True` | Enable telemetry via the Customer Usage Attribution ID (GUID). | | `graphs` | _[graphs](graphs/readme.md)_ array | `[]` | Array of graphs to deploy in the Gremlin database. | -| `maxThroughput` | int | `0` | Represents maximum throughput, the resource can scale up to. | +| `maxThroughput` | int | `4000` | Represents maximum throughput, the resource can scale up to. Cannot be set together with `throughput`. If `throughput` is set to something else than -1, this autoscale setting is ignored. | | `systemAssignedIdentity` | bool | `False` | Enables system assigned managed identity on the resource. | | `tags` | object | `{object}` | Tags of the Gremlin database resource. | -| `throughput` | int | `0` | Request Units per second. For example, "throughput": 10000. | +| `throughput` | int | `-1` | Request Units per second (for example 10000). Cannot be set together with `maxThroughput`. | | `userAssignedIdentities` | object | `{object}` | The ID(s) to assign to the resource. | diff --git a/modules/Microsoft.DocumentDB/databaseAccounts/readme.md b/modules/Microsoft.DocumentDB/databaseAccounts/readme.md index c25ce65b13..86f864d646 100644 --- a/modules/Microsoft.DocumentDB/databaseAccounts/readme.md +++ b/modules/Microsoft.DocumentDB/databaseAccounts/readme.md @@ -563,6 +563,11 @@ userAssignedIdentities: { } ] }, + "capabilitiesToAdd": { + "value": [ + "EnableGremlin" + ] + }, "roleAssignments": { "value": [ { @@ -661,6 +666,9 @@ module databaseAccounts './Microsoft.DocumentDB/databaseAccounts/deploy.bicep' = isZoneRedundant: false } ] + capabilitiesToAdd: [ + 'EnableGremlin' + ] roleAssignments: [ { roleDefinitionIdOrName: 'Reader'