Skip to content

Commit

Permalink
Fixes for identified issues
Browse files Browse the repository at this point in the history
  • Loading branch information
markjbrown committed Sep 11, 2019
1 parent 1e93dba commit 7f49638
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ az cosmosdb collection create \
--db-name $databaseName \
--resource-group $resourceGroupName \
--partition-key-path $partitionKeyPath \
--throughput throughput
--throughput $throughput
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ uniqueId=$(env LC_CTYPE=C tr -dc 'a-z0-9' < /dev/urandom | fold -w 10 | head -n

# Set variables for the new SQL API account
resourceGroupName='myResourceGroup'
location='southcentralus'
location='westus2'
accountName="mycosmosaccount-$uniqueId" #needs to be lower case


Expand All @@ -14,23 +14,26 @@ az group create \
--name $resourceGroupName \
--location $location


# Create a SQL API Cosmos DB account with session consistency
# Create a SQL API Cosmos DB account in three regions
az cosmosdb create \
--resource-group $resourceGroupName \
--name $accountName \
--kind GlobalDocumentDB \
--locations regionName="South Central US" failoverPriority=0 isZoneRedundant=False \
--locations regionName="North Central US" failoverPriority=1 isZoneRedundant=False \
--locations regionName="East US 2" failoverPriority=2 isZoneRedundant=False \
--default-consistency-level "Session"
--locations regionName="West US 2" failoverPriority=0 isZoneRedundant=false \
--locations regionName="North Central US" failoverPriority=1 isZoneRedundant=false \
--locations regionName="East US 2" failoverPriority=2 isZoneRedundant=false

read -p "Press any key to change failover priority regions..."

# Update failover configuration
az cosmosdb update \
# Modify regional failover priorities, (flip East US 2 and North Central US)
az cosmosdb failover-priority-change \
--name $accountName \
--resource-group $resourceGroupName \
--locations regionName="South Central US" failoverPriority=0 isZoneRedundant=False \
--locations regionName="East US 2" failoverPriority=1 isZoneRedundant=False \
--locations regionName="North Central US" failoverPriority=2 isZoneRedundant=False \
--failover-policies 'West US 2'=0 "North Central US"=1 "East US 2"=2

read -p "Press any key to initiate a manual failover to secondary region..."

# Initiate regional failover, (promote secondary region to region 0)
az cosmosdb failover-priority-change \
--name $accountName \
--resource-group $resourceGroupName \
--failover-policies 'North Central US'=0 "West US 2"=1 "East US 2"=2
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 cosmosdb/scale-cosmosdb-throughput/scale-cosmosdb-throughput.sh
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ az cosmosdb create \
az cosmosdb update \
--name $accountName \
--resource-group $resourceGroupName \
--ip-range-filter $ipRangeFilter
--ip-range-filter $ipRangeFilter
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ read -p "Press any key to regenerate account keys..."
az cosmosdb regenerate-key \
--name $accountName \
--resource-group $resourceGroupName \
--key-kind secondary
--key-kind secondary

0 comments on commit 7f49638

Please sign in to comment.