Exercise 2: Using the Azure CLI to Provision Cosmos DB
Let us take a close look at the SQL API. The documents you will create in the container will be stored in JSON format and can be indexed and searched by SQL queries using the properties you provide. In the following script, you will build a new account-supported SQL API and a container with provisioned throughput.
Note
The following exercise can be executed from Bash on localhost or Cloud Shell from the Azure portal.
The code accompanying the steps can also be found here: https://packt.link/FUn0X
- Create the resource group:
az group create -l canadacentral -n CosmosDB-RG
- To avoid name collisions, generate a unique name for your database:
account=cosmosdb-$RANDOM
- Create the Cosmos DB account:
az cosmosdb create --name $account --resource-group CosmosDB-RG
- Create the Cosmos DB database with the SQL API:
az cosmosdb sql database create --account-name $account --resource-group CosmosDB-RG --name AZ204Demo
...