forked from Azure-Samples/azure-cli-samples
-
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.
- Loading branch information
1 parent
1e93dba
commit 7f49638
Showing
6 changed files
with
110 additions
and
124 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
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
79 changes: 31 additions & 48 deletions
79
...db/scale-cosmosdb-replicate-multiple-regions/scale-cosmosdb-replicate-multiple-regions.sh
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 |
---|---|---|
@@ -1,48 +1,31 @@ | ||
#!/bin/bash | ||
|
||
# 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) | ||
|
||
# Set variables for the new SQL API account | ||
resourceGroupName='myResourceGroup' | ||
location='southcentralus' | ||
accountName="mycosmosaccount-$uniqueId" #needs to be lower case | ||
|
||
# Create a resource group | ||
az group create \ | ||
--name $resourceGroupName \ | ||
--location $location | ||
|
||
|
||
# Create a SQL API Cosmos DB account with session consistency | ||
az cosmosdb create \ | ||
--name $accountName \ | ||
--kind GlobalDocumentDB \ | ||
--resource-group $resourceGroupName \ | ||
--default-consistency-level "Session" | ||
|
||
|
||
read -p "Press any key to add locations..." | ||
|
||
|
||
# Replicate in multiple regions | ||
az cosmosdb update \ | ||
--name $accountName \ | ||
--resource-group $resourceGroupName \ | ||
--locations regionName="South Central US" failoverPriority=0 \ | ||
--locations regionName="North Central US" failoverPriority=1 \ | ||
--locations regionName="East US" failoverPriority=2 \ | ||
--locations regionName="West US" failoverPriority=3 | ||
|
||
|
||
read -p "Press any key to change failover regions..." | ||
|
||
|
||
# Modify regional failover priorities | ||
az cosmosdb update \ | ||
--name $accountName \ | ||
--resource-group $resourceGroupName \ | ||
--locations regionName="South Central US" failoverPriority=3 \ | ||
--locations regionName="North Central US" failoverPriority=2 \ | ||
--locations regionName="East US" failoverPriority=1 \ | ||
--locations regionName="West US" failoverPriority=0 | ||
#!/bin/bash | ||
|
||
# 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) | ||
|
||
# Set variables for the new SQL API account | ||
resourceGroupName='myResourceGroup' | ||
location='southcentralus' | ||
accountName="mycosmosaccount-$uniqueId" #needs to be lower case | ||
|
||
# Create a resource group | ||
az group create \ | ||
--name $resourceGroupName \ | ||
--location $location | ||
|
||
|
||
# Create a SQL API Cosmos DB account in resource group region | ||
az cosmosdb create \ | ||
--name $accountName \ | ||
--resource-group $resourceGroupName | ||
|
||
|
||
read -p "Press any key to add 2 regions..." | ||
|
||
# Add additional 2 regions | ||
az cosmosdb update \ | ||
--name $accountName \ | ||
--resource-group $resourceGroupName \ | ||
--locations regionName="West US 2" failoverPriority=0 isZoneRedundant=false \ | ||
--locations regionName="East US 2" failoverPriority=1 isZoneRedundant=false \ | ||
--locations regionName="North Central US" failoverPriority=2 isZoneRedundant=false |
120 changes: 60 additions & 60 deletions
120
cosmosdb/scale-cosmosdb-throughput/scale-cosmosdb-throughput.sh
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 |
---|---|---|
@@ -1,60 +1,60 @@ | ||
#!/bin/bash | ||
|
||
# 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) | ||
|
||
# Set variables for the new SQL API account, database, and container | ||
resourceGroupName='myResourceGroup' | ||
location='southcentralus' | ||
accountName="mycosmosaccount-$uniqueId" #needs to be lower case | ||
databaseName='myDatabase' | ||
containerName='myContainer' | ||
partitionKeyPath='/myPartitionKey' #property to partition data on | ||
originalThroughput=400 | ||
newThroughput=500 | ||
|
||
|
||
# Create a resource group | ||
az group create \ | ||
--name $resourceGroupName \ | ||
--location $location | ||
|
||
|
||
# Create a SQL API Cosmos DB account with session consistency and multi-master enabled | ||
az cosmosdb create \ | ||
--name $accountName \ | ||
--kind GlobalDocumentDB \ | ||
--locations regionName="South Central US" failoverPriority=0 \ | ||
--locations regionName="North Central US" failoverPriority=1 \ | ||
--resource-group $resourceGroupName \ | ||
--default-consistency-level "Session" \ | ||
--enable-multiple-write-locations true | ||
|
||
|
||
# Create a database | ||
az cosmosdb database create \ | ||
--name $accountName \ | ||
--db-name $databaseName \ | ||
--resource-group $resourceGroupName | ||
|
||
|
||
# Create a partitioned container with 400 RU/s | ||
az cosmosdb collection create \ | ||
--resource-group $resourceGroupName \ | ||
--collection-name $containerName \ | ||
--name $accountName \ | ||
--db-name $databaseName \ | ||
--partition-key-path $partitionKeyPath \ | ||
--throughput $originalThroughput | ||
|
||
|
||
read -p "Press any key to set new throughput..." | ||
|
||
|
||
# Scale throughput to 500 RU/s | ||
az cosmosdb collection update \ | ||
--collection-name $containerName \ | ||
--name $accountName \ | ||
--db-name $databaseName \ | ||
--resource-group $resourceGroupName \ | ||
--throughput $newThroughput | ||
#!/bin/bash | ||
|
||
# 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) | ||
|
||
# Set variables for the new SQL API account, database, and container | ||
resourceGroupName='myResourceGroup' | ||
location='southcentralus' | ||
accountName="mycosmosaccount-$uniqueId" #needs to be lower case | ||
databaseName='myDatabase' | ||
containerName='myContainer' | ||
partitionKeyPath='/myPartitionKey' #property to partition data on | ||
originalThroughput=400 | ||
newThroughput=500 | ||
|
||
|
||
# Create a resource group | ||
az group create \ | ||
--name $resourceGroupName \ | ||
--location $location | ||
|
||
|
||
# Create a SQL API Cosmos DB account with session consistency and multi-master enabled | ||
az cosmosdb create \ | ||
--name $accountName \ | ||
--kind GlobalDocumentDB \ | ||
--locations regionName="South Central US" failoverPriority=0 \ | ||
--locations regionName="North Central US" failoverPriority=1 \ | ||
--resource-group $resourceGroupName \ | ||
--default-consistency-level "Session" \ | ||
--enable-multiple-write-locations true | ||
|
||
|
||
# Create a database | ||
az cosmosdb database create \ | ||
--name $accountName \ | ||
--db-name $databaseName \ | ||
--resource-group $resourceGroupName | ||
|
||
|
||
# Create a partitioned container with 400 RU/s | ||
az cosmosdb collection create \ | ||
--resource-group $resourceGroupName \ | ||
--collection-name $containerName \ | ||
--name $accountName \ | ||
--db-name $databaseName \ | ||
--partition-key-path $partitionKeyPath \ | ||
--throughput $originalThroughput | ||
|
||
|
||
read -p "Press any key to set new throughput..." | ||
|
||
|
||
# Scale throughput to 500 RU/s | ||
az cosmosdb collection update \ | ||
--collection-name $containerName \ | ||
--name $accountName \ | ||
--db-name $databaseName \ | ||
--resource-group $resourceGroupName \ | ||
--throughput $newThroughput |
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
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