Skip to content

Commit

Permalink
Fixes for issues in PR
Browse files Browse the repository at this point in the history
  • Loading branch information
markjbrown committed Sep 5, 2019
1 parent 25f15da commit 1e93dba
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 101 deletions.
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
#!/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 MongoDB API account and database
resourceGroupName='myResourceGroup'
location='southcentralus'
accountName="mycosmosaccount-$uniqueId" #needs to be lower case
databaseName='myDatabase'
collectionName='myCollection'
partitionKeyPath='/myPartitionKey' #property to partition data on
throughput=400


# Create a resource group
az group create \
--name $resourceGroupName \
--location $location


# Create a MongoDB API Cosmos account with consistent prefix (Local) consistency,
# multi-master enabled with replicas in two regions
az cosmosdb create \
--resource-group $resourceGroupName \
--name $accountName \
--kind MongoDB \
--locations regionName="South Central US" failoverPriority=0 \
--locations regionName="North Central US" failoverPriority=1 \
--default-consistency-level "ConsistentPrefix" \
--enable-multiple-write-locations true


# Create a database
az cosmosdb database create \
--resource-group $resourceGroupName \
--name $accountName \
--db-name $databaseName


# Create a MongoDB collection with a partition key and 400 RU/s
az cosmosdb collection create \
--resource-group $resourceGroupName \
--collection-name $collectionName \
--name $accountName \
--db-name $databaseName \
--partition-key-path $partitionKeyPath \
--throughput $throughput
#!/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 MongoDB API account and database
resourceGroupName='myResourceGroup'
location='southcentralus'
accountName="mycosmosaccount-$uniqueId" #needs to be lower case
databaseName='myDatabase'
collectionName='myCollection'
partitionKeyPath='/myPartitionKey' #property to partition data on
throughput=400


# Create a resource group
az group create \
--name $resourceGroupName \
--location $location


# Create a MongoDB API Cosmos account with consistent prefix (Local) consistency,
# multi-master enabled with replicas in two regions
az cosmosdb create \
--resource-group $resourceGroupName \
--name $accountName \
--kind MongoDB \
--locations regionName="South Central US" failoverPriority=0 \
--locations regionName="North Central US" failoverPriority=1 \
--default-consistency-level "ConsistentPrefix" \
--enable-multiple-write-locations true


# Create a database
az cosmosdb database create \
--resource-group $resourceGroupName \
--name $accountName \
--db-name $databaseName


# Create a MongoDB collection with a partition key and 400 RU/s
az cosmosdb collection create \
--resource-group $resourceGroupName \
--collection-name $collectionName \
--name $accountName \
--db-name $databaseName \
--partition-key-path $partitionKeyPath \
--throughput $throughput
Original file line number Diff line number Diff line change
@@ -1,45 +1,45 @@
#!/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 Table API account, database, and table
resourceGroupName='myResourceGroup'
location='southcentralus'
accountName="mycosmosaccount-$uniqueId" #needs to be lower case
databaseName='myDatabase'
tableName='myTable'
throughput=400

# Create a resource group
az group create \
--name $resourceGroupName \
--location $location


# Create a Table API Cosmos DB account with Session level consistency
# multi-master enabled with replicas in two regions
az cosmosdb create \
--resource-group $resourceGroupName \
--name $accountName \
--capabilities EnableTable \
--locations regionName="South Central US" failoverPriority=0 \
--locations regionName="North Central US" failoverPriority=1 \
--default-consistency-level "Session" \
--enable-multiple-write-locations true


# Create a database
az cosmosdb database create \
--resource-group $resourceGroupName \
--name $accountName \
--db-name $databaseName


# Create a Table API table with 400 RU/s
az cosmosdb collection create \
--resource-group $resourceGroupName \
--collection-name $tableName \
--name $accountName \
--db-name $databaseName \
--throughput $throughput
#!/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 Table API account, database, and table
resourceGroupName='myResourceGroup'
location='southcentralus'
accountName="mycosmosaccount-$uniqueId" #needs to be lower case
databaseName='myDatabase'
tableName='myTable'
throughput=400

# Create a resource group
az group create \
--name $resourceGroupName \
--location $location


# Create a Table API Cosmos DB account with Session level consistency
# multi-master enabled with replicas in two regions
az cosmosdb create \
--resource-group $resourceGroupName \
--name $accountName \
--capabilities EnableTable \
--locations regionName="South Central US" failoverPriority=0 \
--locations regionName="North Central US" failoverPriority=1 \
--default-consistency-level "Session" \
--enable-multiple-write-locations true


# Create a database
az cosmosdb database create \
--resource-group $resourceGroupName \
--name $accountName \
--db-name $databaseName


# Create a Table API table with 400 RU/s
az cosmosdb collection create \
--resource-group $resourceGroupName \
--collection-name $tableName \
--name $accountName \
--db-name $databaseName \
--throughput $throughput
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ az cosmosdb create \
--resource-group $resourceGroupName \
--name $accountName \
--kind GlobalDocumentDB \
--locations regionName="South Central US" failoverPriority=0 \
--locations regionName="North Central US" failoverPriority=1 \
--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"


# Update failover configuration
az cosmosdb update \
--name $accountName \
--resource-group $resourceGroupName \
--locations "South Central US"=0 "North Central US"=1 "East US 2"=2 "West US 2"=3
--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 \

Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ az cosmosdb collection update \
--name $accountName \
--db-name $databaseName \
--resource-group $resourceGroupName \
--throughput $newThroughput
--throughput $newThroughput
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@ az cosmosdb create \
--locations regionName="South Central US" failoverPriority=0 \
--locations regionName="North Central US" failoverPriority=1 \
--default-consistency-level "Session" \
--enable-multiple-write-locations true
--enable-multiple-write-locations false


# Get the connection string with Primary Key for Cosmos DB account
endpoint=$(az cosmosdb show -g $myRG -n $myDB --query 'documentEndpoint' -o tsv)
key=$(az cosmosdb list-keys -g $myRG -n $myDB --query 'primaryMasterKey' -o tsv)
connection="AccountEndpoint=$endpoint/;AccountKey=$key;"
connection=$(az cosmosdb list-connection-strings -n $accountName -g $resourceGroupName)
echo $connection

0 comments on commit 1e93dba

Please sign in to comment.