Skip to content

Commit 8b9cd89

Browse files
Merge pull request #112909 from markjbrown/update-oss-arm-samples
update OSS API ARM template samples
2 parents 3ee5bf6 + 0098dde commit 8b9cd89

File tree

4 files changed

+791
-42
lines changed

4 files changed

+791
-42
lines changed

articles/cosmos-db/manage-cassandra-with-resource-manager.md

Lines changed: 193 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
title: Resource Manager templates for Azure Cosmos DB Cassandra API
33
description: Use Azure Resource Manager templates to create and configure Azure Cosmos DB Cassandra API.
4-
author: TheovanKraay
4+
author: markjbrown
55
ms.service: cosmos-db
66
ms.topic: conceptual
7-
ms.date: 11/12/2019
8-
ms.author: thvankra
7+
ms.date: 04/27/2020
8+
ms.author: mjbrown
99
---
1010

1111
# Manage Azure Cosmos DB Cassandra API resources using Azure Resource Manager templates
1212

13-
This article describes how to perform different operations to automate management of your Azure Cosmos DB accounts, databases and containers using Azure Resource Manager templates. This article has examples for SQL API accounts only, to find examples for other API type accounts see: use Azure Resource Manager templates with Azure Cosmos DB's API for [SQL](manage-sql-with-resource-manager.md), [Gremlin](manage-gremlin-with-resource-manager.md), [MongoDB](manage-mongodb-with-resource-manager.md), [Table](manage-table-with-resource-manager.md) articles.
13+
This article describes how to perform different operations to automate management of your Azure Cosmos DB accounts, databases and containers using Azure Resource Manager templates. This article has examples for Cassandra API accounts only, to find examples for other API type accounts see: use Azure Resource Manager templates with Azure Cosmos DB's API for [SQL](manage-sql-with-resource-manager.md), [Gremlin](manage-gremlin-with-resource-manager.md), [MongoDB](manage-mongodb-with-resource-manager.md), [Table](manage-table-with-resource-manager.md) articles.
1414

1515
## Create Azure Cosmos account, keyspace and table <a id="create-resource"></a>
1616

@@ -20,7 +20,190 @@ Create Azure Cosmos DB resources using an Azure Resource Manager template. This
2020
> Account names must be lowercase and 44 or fewer characters.
2121
> To update RU/s, resubmit the template with updated throughput property values.
2222
23-
:::code language="json" source="~/quickstart-templates/101-cosmosdb-cassandra/azuredeploy.json":::
23+
```json
24+
{
25+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
26+
"contentVersion": "1.0.0.0",
27+
"parameters": {
28+
"accountName": {
29+
"type": "string",
30+
"defaultValue": "",
31+
"metadata": {
32+
"description": "Cosmos DB account name, max length 44 characters"
33+
}
34+
},
35+
"location": {
36+
"type": "string",
37+
"defaultValue": "[resourceGroup().location]",
38+
"metadata": {
39+
"description": "Location for the Cosmos DB account."
40+
}
41+
},
42+
"primaryRegion":{
43+
"type":"string",
44+
"metadata": {
45+
"description": "The primary replica region for the Cosmos DB account."
46+
}
47+
},
48+
"secondaryRegion":{
49+
"type":"string",
50+
"metadata": {
51+
"description": "The secondary replica region for the Cosmos DB account."
52+
}
53+
},
54+
"defaultConsistencyLevel": {
55+
"type": "string",
56+
"defaultValue": "Session",
57+
"allowedValues": [ "Eventual", "ConsistentPrefix", "Session", "BoundedStaleness", "Strong" ],
58+
"metadata": {
59+
"description": "The default consistency level of the Cosmos DB account."
60+
}
61+
},
62+
"maxStalenessPrefix": {
63+
"type": "int",
64+
"defaultValue": 100000,
65+
"minValue": 10,
66+
"maxValue": 1000000,
67+
"metadata": {
68+
"description": "Max stale requests. Required for BoundedStaleness. Valid ranges, Single Region: 10 to 1000000. Multi Region: 100000 to 1000000."
69+
}
70+
},
71+
"maxIntervalInSeconds": {
72+
"type": "int",
73+
"defaultValue": 300,
74+
"minValue": 5,
75+
"maxValue": 86400,
76+
"metadata": {
77+
"description": "Max lag time (seconds). Required for BoundedStaleness. Valid ranges, Single Region: 5 to 84600. Multi Region: 300 to 86400."
78+
}
79+
},
80+
"automaticFailover": {
81+
"type": "bool",
82+
"defaultValue": true,
83+
"allowedValues": [ true, false ],
84+
"metadata": {
85+
"description": "Enable automatic failover for regions"
86+
}
87+
},
88+
"keyspaceName": {
89+
"type": "string",
90+
"defaultValue": "Keyspace1",
91+
"metadata": {
92+
"description": "The name for the Cassandra Keyspace"
93+
}
94+
},
95+
"tableName": {
96+
"type": "string",
97+
"defaultValue": "Table1",
98+
"metadata": {
99+
"description": "The name for the Cassandra table"
100+
}
101+
},
102+
"throughput": {
103+
"type": "int",
104+
"defaultValue": 400,
105+
"minValue": 400,
106+
"maxValue": 1000000,
107+
"metadata": {
108+
"description": "The throughput for the Cassandra table"
109+
}
110+
}
111+
},
112+
"variables": {
113+
"accountName": "[toLower(parameters('accountName'))]",
114+
"consistencyPolicy": {
115+
"Eventual": {
116+
"defaultConsistencyLevel": "Eventual"
117+
},
118+
"ConsistentPrefix": {
119+
"defaultConsistencyLevel": "ConsistentPrefix"
120+
},
121+
"Session": {
122+
"defaultConsistencyLevel": "Session"
123+
},
124+
"BoundedStaleness": {
125+
"defaultConsistencyLevel": "BoundedStaleness",
126+
"maxStalenessPrefix": "[parameters('maxStalenessPrefix')]",
127+
"maxIntervalInSeconds": "[parameters('maxIntervalInSeconds')]"
128+
},
129+
"Strong": {
130+
"defaultConsistencyLevel": "Strong"
131+
}
132+
},
133+
"locations":
134+
[
135+
{
136+
"locationName": "[parameters('primaryRegion')]",
137+
"failoverPriority": 0,
138+
"isZoneRedundant": false
139+
},
140+
{
141+
"locationName": "[parameters('secondaryRegion')]",
142+
"failoverPriority": 1,
143+
"isZoneRedundant": false
144+
}
145+
]
146+
},
147+
"resources":
148+
[
149+
{
150+
"type": "Microsoft.DocumentDB/databaseAccounts",
151+
"name": "[variables('accountName')]",
152+
"apiVersion": "2020-03-01",
153+
"location": "[parameters('location')]",
154+
"kind": "GlobalDocumentDB",
155+
"properties": {
156+
"capabilities": [{ "name": "EnableCassandra" }],
157+
"consistencyPolicy": "[variables('consistencyPolicy')[parameters('defaultConsistencyLevel')]]",
158+
"locations": "[variables('locations')]",
159+
"databaseAccountOfferType": "Standard",
160+
"enableAutomaticFailover": "[parameters('automaticFailover')]"
161+
}
162+
},
163+
{
164+
"type": "Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces",
165+
"name": "[concat(variables('accountName'), '/', parameters('keyspaceName'))]",
166+
"apiVersion": "2020-03-01",
167+
"dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts/', variables('accountName'))]" ],
168+
"properties":{
169+
"resource":{
170+
"id": "[parameters('keyspaceName')]"
171+
}
172+
}
173+
},
174+
{
175+
"type": "Microsoft.DocumentDb/databaseAccounts/cassandraKeyspaces/tables",
176+
"name": "[concat(variables('accountName'), '/', parameters('keyspaceName'), '/', parameters('tableName'))]",
177+
"apiVersion": "2020-03-01",
178+
"dependsOn": [ "[resourceId('Microsoft.DocumentDB/databaseAccounts/cassandraKeyspaces', variables('accountName'), parameters('keyspaceName'))]" ],
179+
"properties":
180+
{
181+
"resource":{
182+
"id": "[parameters('tableName')]",
183+
"schema": {
184+
"columns": [
185+
{ "name": "loadid", "type": "uuid" },
186+
{ "name": "machine", "type": "uuid" },
187+
{ "name": "cpu", "type": "int" },
188+
{ "name": "mtime", "type": "int" },
189+
{ "name": "load", "type": "float" }
190+
],
191+
"partitionKeys": [
192+
{ "name": "machine" },
193+
{ "name": "cpu" },
194+
{ "name": "mtime" }
195+
],
196+
"clusterKeys": [
197+
{ "name": "loadid", "orderBy": "asc" }
198+
]
199+
},
200+
"options": { "throughput": "[parameters('throughput')]" }
201+
}
202+
}
203+
}
204+
]
205+
}
206+
```
24207

25208
## Deploy with the Azure CLI
26209

@@ -33,22 +216,21 @@ read -p 'Enter the location (i.e. westus2): ' location
33216
read -p 'Enter the account name: ' accountName
34217
read -p 'Enter the primary region (i.e. westus2): ' primaryRegion
35218
read -p 'Enter the secondary region (i.e. eastus2): ' secondaryRegion
36-
read -p 'Enter the keyset name: ' keysetName
37-
read -p 'Enter the first table name: ' table1Name
38-
read -p 'Enter the second table name: ' table2Name
219+
read -p 'Enter the keyspace name: ' keyspaceName
220+
read -p 'Enter the table name: ' tableName
221+
read -p 'Enter the throughput: ' throughput
39222
40223
az group create --name $resourceGroupName --location $location
41224
az group deployment create --resource-group $resourceGroupName \
42225
--template-uri https://raw.githubusercontent.com/azure/azure-quickstart-templates/master/101-cosmosdb-cassandra/azuredeploy.json \
43-
--parameters accountName=$accountName primaryRegion=$primaryRegion secondaryRegion=$secondaryRegion keysetName=$keysetName \
44-
table1Name=$table1Name table2Name=$table2Name
226+
--parameters accountName=$accountName primaryRegion=$primaryRegion secondaryRegion=$secondaryRegion keyspaceName=$keyspaceName \
227+
tableName=$tableName throughput=$throughput
45228
46229
az cosmosdb show --resource-group $resourceGroupName --name accountName --output tsv
47230
```
48231

49232
The `az cosmosdb show` command shows the newly created Azure Cosmos account after it has been provisioned. If you choose to use a locally installed version of the Azure CLI instead of using Cloud Shell, see the [Azure CLI](/cli/azure/) article.
50233

51-
52234
## Next steps
53235

54236
Here are some additional resources:

0 commit comments

Comments
 (0)