forked from Azure-Samples/azure-cli-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththroughput.sh
More file actions
54 lines (43 loc) · 1.44 KB
/
Copy paththroughput.sh
File metadata and controls
54 lines (43 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
!/bin/bash
# Update throughput for a SQL API database and container
# Generate a unique 10 character alphanumeric string to ensure unique resource names
uniqueId=$(env LC_CTYPE=C tr -dc 'a-z0-9' < /dev/urandom | fold -w 10 | head -n 1)
# Variables for SQL API resources
resourceGroupName="Group-$uniqueId"
location='westus2'
accountName="cosmos-$uniqueId" #needs to be lower case
databaseName='database1'
containerName='container1'
# Create a resource group
az group create -n $resourceGroupName -l $location
# Create a Cosmos account for SQL API
az cosmosdb create \
-n $accountName \
-g $resourceGroupName
# Create a SQL API database with shared throughput
az cosmosdb sql database create \
-a $accountName \
-g $resourceGroupName \
-n $databaseName \
--throughput 400
# Create a SQL API container, default index policy, dedicated throughput
az cosmosdb sql container create \
-a $accountName \
-g $resourceGroupName \
-d $databaseName \
-n $containerName \
-p '/id' \
--throughput 400
read -p 'Press any key to increase Database throughput to 500'
az cosmosdb sql database throughput update \
-a $accountName \
-g $resourceGroupName \
-n $databaseName \
--throughput 400
read -p 'Press any key to increase Container throughput to 500'
az cosmosdb sql container throughput update \
-a $accountName \
-g $resourceGroupName \
-d $databaseName \
-n $containerName \
--throughput 500