forked from Azure/azure-quickstart-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Azure#6085 from markjbrown/MongoDB-API
New MongoDB API Template
- Loading branch information
Showing
4 changed files
with
260 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Create an Azure Cosmos account for MongoDB API with two collections | ||
|
||
This template creates an Azure Cosmos account for MongoDB API, provisioned for two regions, then provision a database with throughput shared across 2 collections. | ||
|
||
Below are the parameters which can be user configured in the parameters file including: | ||
|
||
- **Consistency Level:** Select from one of the 5 consistency levels: Strong, Bounded Staleness, Session, Consistent Prefix, Eventual. | ||
- **Multi-Region:** Enter locations for primary and secondary regions. | ||
- **Multi-Master:** Select whether to enable multi-master support making both regions fully writable. | ||
- **Automatic Failover:** Select whether to enable automatic failover on the account (Ignored when Multi-Master is enabled). | ||
- **Database Name:** Enter the database name for the account. | ||
- **Throughput:** Enter the Ru/s to share across the 2 containers (default is 400). | ||
- **Collection 1 Name:** Enter the name for the first collection. | ||
- **Collection 2 Name:** Enter the name for the second collection. | ||
|
||
<a href="https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-cosmosdb-mongodb%2Fazuredeploy.json" target="_blank"> | ||
<img src="http://azuredeploy.net/deploybutton.png"/> | ||
</a> | ||
<a href="http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2F101-cosmosdb-mongodb%2Fazuredeploy.json" target="_blank"> | ||
<img src="http://armviz.io/visualizebutton.png"/> | ||
</a> |
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,206 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"accountName": { | ||
"type": "string", | ||
"defaultValue": "[concat('mongodb-', uniqueString(resourceGroup().id))]", | ||
"metadata": { | ||
"description": "Cosmos DB account name" | ||
} | ||
}, | ||
"location": { | ||
"type": "string", | ||
"defaultValue": "[resourceGroup().location]", | ||
"metadata": { | ||
"description": "Location for the Cosmos DB account." | ||
} | ||
}, | ||
"primaryRegion":{ | ||
"type":"string", | ||
"metadata": { | ||
"description": "The primary replica region for the Cosmos DB account." | ||
} | ||
}, | ||
"secondaryRegion":{ | ||
"type":"string", | ||
"metadata": { | ||
"description": "The secondary replica region for the Cosmos DB account." | ||
} | ||
}, | ||
"defaultConsistencyLevel": { | ||
"type": "string", | ||
"defaultValue": "Session", | ||
"allowedValues": [ "Eventual", "ConsistentPrefix", "Session", "BoundedStaleness", "Strong" ], | ||
"metadata": { | ||
"description": "The default consistency level of the Cosmos DB account." | ||
} | ||
}, | ||
"maxStalenessPrefix": { | ||
"type": "int", | ||
"defaultValue": 100000, | ||
"minValue": 10, | ||
"maxValue": 2147483647, | ||
"metadata": { | ||
"description": "Max stale requests. Required for BoundedStaleness. Valid ranges, Single Region: 10 to 1000000. Multi Region: 100000 to 1000000." | ||
} | ||
}, | ||
"maxIntervalInSeconds": { | ||
"type": "int", | ||
"defaultValue": 300, | ||
"minValue": 5, | ||
"maxValue": 86400, | ||
"metadata": { | ||
"description": "Max lag time (seconds). Required for BoundedStaleness. Valid ranges, Single Region: 5 to 84600. Multi Region: 300 to 86400." | ||
} | ||
}, | ||
"multipleWriteLocations": { | ||
"type": "bool", | ||
"defaultValue": true, | ||
"allowedValues": [ true, false ], | ||
"metadata": { | ||
"description": "Enable multi-master to make all regions writable." | ||
} | ||
}, | ||
"databaseName": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The name for the Mongo DB database" | ||
} | ||
}, | ||
"throughput": { | ||
"type": "int", | ||
"defaultValue": 400, | ||
"minValue": 400, | ||
"maxValue": 1000000, | ||
"metadata": { | ||
"description": "The throughput for the Mongo DB database" | ||
} | ||
}, | ||
"collection1Name": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The name for the first Mongo DB collection" | ||
} | ||
}, | ||
"collection2Name": { | ||
"type": "string", | ||
"metadata": { | ||
"description": "The name for the second Mongo DB collection" | ||
} | ||
} | ||
}, | ||
"variables": { | ||
"accountName": "[toLower(parameters('accountName'))]", | ||
"consistencyPolicy": { | ||
"Eventual": { | ||
"defaultConsistencyLevel": "Eventual" | ||
}, | ||
"ConsistentPrefix": { | ||
"defaultConsistencyLevel": "ConsistentPrefix" | ||
}, | ||
"Session": { | ||
"defaultConsistencyLevel": "Session" | ||
}, | ||
"BoundedStaleness": { | ||
"defaultConsistencyLevel": "BoundedStaleness", | ||
"maxStalenessPrefix": "[parameters('maxStalenessPrefix')]", | ||
"maxIntervalInSeconds": "[parameters('maxIntervalInSeconds')]" | ||
}, | ||
"Strong": { | ||
"defaultConsistencyLevel": "Strong" | ||
} | ||
}, | ||
"locations": | ||
[ | ||
{ | ||
"locationName": "[parameters('primaryRegion')]", | ||
"failoverPriority": 0 | ||
}, | ||
{ | ||
"locationName": "[parameters('secondaryRegion')]", | ||
"failoverPriority": 1 | ||
} | ||
] | ||
}, | ||
"resources": | ||
[ | ||
{ | ||
"type": "Microsoft.DocumentDB/databaseAccounts", | ||
"name": "[variables('accountName')]", | ||
"apiVersion": "2016-03-31", | ||
"location": "[parameters('location')]", | ||
"kind": "MongoDB", | ||
"properties": { | ||
"consistencyPolicy": "[variables('consistencyPolicy')[parameters('defaultConsistencyLevel')]]", | ||
"locations": "[variables('locations')]", | ||
"databaseAccountOfferType": "Standard", | ||
"enableMultipleWriteLocations": "[parameters('multipleWriteLocations')]" | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.DocumentDB/databaseAccounts/apis/databases", | ||
"name": "[concat(variables('accountName'), '/mongodb/', parameters('databaseName'))]", | ||
"apiVersion": "2016-03-31", | ||
"dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts/', variables('accountName'))]" ], | ||
"properties":{ | ||
"resource":{ | ||
"id": "[parameters('databaseName')]" | ||
}, | ||
"options": { "throughput": "[parameters('throughput')]" } | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.DocumentDb/databaseAccounts/apis/databases/collections", | ||
"name": "[concat(variables('accountName'), '/mongodb/', parameters('databaseName'), '/', parameters('collection1Name'))]", | ||
"apiVersion": "2016-03-31", | ||
"dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', variables('accountName'), 'mongodb', parameters('databaseName'))]" ], | ||
"properties": | ||
{ | ||
"resource":{ | ||
"id": "[parameters('collection1Name')]", | ||
"shardKey": { "user_id": "Hash" }, | ||
"indexes": [ | ||
{ | ||
"key": { "keys":["user_id", "user_address"] }, | ||
"options": { "unique": "true" } | ||
}, | ||
{ | ||
"key": { "keys":["_ts"] }, | ||
"options": { "expireAfterSeconds": "2629746" } | ||
} | ||
], | ||
"options": { | ||
"If-Match": "<ETag>" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.DocumentDb/databaseAccounts/apis/databases/collections", | ||
"name": "[concat(variables('accountName'), '/mongodb/', parameters('databaseName'), '/', parameters('collection2Name'))]", | ||
"apiVersion": "2016-03-31", | ||
"dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', variables('accountName'), 'mongodb', parameters('databaseName'))]" ], | ||
"properties": | ||
{ | ||
"resource":{ | ||
"id": "[parameters('collection2Name')]", | ||
"shardKey": { "company_id": "Hash" }, | ||
"indexes": [ | ||
{ | ||
"key": { "keys":["company_id", "company_address"] }, | ||
"options": { "unique": "true" } | ||
}, | ||
{ | ||
"key": { "keys":["_ts"] }, | ||
"options": { "expireAfterSeconds": "2629746" } | ||
} | ||
], | ||
"options": { | ||
"If-Match": "<ETag>" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
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,24 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"accountName": { | ||
"value": "GEN-UNIQUE" | ||
}, | ||
"primaryRegion": { | ||
"value": "West US" | ||
}, | ||
"secondaryRegion": { | ||
"value": "East US" | ||
}, | ||
"databaseName": { | ||
"value": "myDatabase" | ||
}, | ||
"collection1Name": { | ||
"value": "myCollection1" | ||
}, | ||
"collection2Name": { | ||
"value": "myCollection2" | ||
} | ||
} | ||
} |
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,9 @@ | ||
{ | ||
"$schema": "https://aka.ms/azure-quickstart-templates-metadata-schema#", | ||
"type": "QuickStart", | ||
"itemDisplayName": "Create an Azure Cosmos DB account for MongoDB API", | ||
"description": "This template creates an Azure Cosmos DB account for MongoDB API in two regions using shared throughput at database level with two collections.", | ||
"summary": "This template creates an Azure Cosmos DB account for MongoDB API in two regions using shared throughput at database level with two collections.", | ||
"githubUsername": "markjbrown", | ||
"dateUpdated": "2019-04-25" | ||
} |