Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save actionjack/3c8940ea3527d4f508c844b480fcda3b to your computer and use it in GitHub Desktop.
Save actionjack/3c8940ea3527d4f508c844b480fcda3b to your computer and use it in GitHub Desktop.
Create a sharded MongoDB in CosmosDB using the Azure CLI
#!/bin/bash
resourceGroupName="cosmosdbshardedtest"
name="mongodboncosmosdb"
databaseName="mongodb"
collectionName="mongodbcoll"
kind="MongoDB"
partition="/'\$v'/YourShardID/'\$v'"
az login
az group create --name $resourceGroupName --location westeurope
az cosmosdb create --name $name --kind $kind --resource-group $resourceGroupName
az cosmosdb database create --name $name --db-name $databaseName --resource-group $resourceGroupName
az cosmosdb collection create --collection-name $collectionName --name $name --db-name $databaseName --resource-group $resourceGroupName --partition-key-path $partition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment