az cosmosdb sql container

Manage Azure Cosmos DB SQL containers.

Commands

az cosmosdb sql container create

Create an SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container delete

Delete the SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container exists

Checks if an Azure Cosmos DB SQL container exists.

az cosmosdb sql container list

List the SQL containers under an Azure Cosmos DB SQL database.

az cosmosdb sql container merge

Merges the partitions of a sql container.

az cosmosdb sql container redistribute-partition-throughput

Redistributes the partition throughput of a sql container.

az cosmosdb sql container restore

Restore a deleted sql container within the same account.

az cosmosdb sql container retrieve-partition-throughput

Retrieve the partition throughput of a sql container.

az cosmosdb sql container show

Show the details of a SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container throughput

Manage throughput of SQL container under an Azure Cosmos DB account.

az cosmosdb sql container throughput migrate

Migrate the throughput of the SQL container between autoscale and manually provisioned.

az cosmosdb sql container throughput show

Get the throughput of the SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container throughput update

Update the throughput of the SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container update

Update an SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container create

Create an SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container create --account-name
                                 --database-name
                                 --name
                                 --partition-key-path
                                 --resource-group
                                 [--analytical-storage-ttl]
                                 [--cep]
                                 [--conflict-resolution-policy]
                                 [--idx]
                                 [--max-throughput]
                                 [--partition-key-version]
                                 [--throughput]
                                 [--ttl]
                                 [--unique-key-policy]

Examples

Create an Azure Cosmos DB SQL container.

az cosmosdb sql container create -g MyResourceGroup -a MyAccount -d MyDatabase -n MyContainer --partition-key-path "/my/path" --idx @policy-file.json --ttl 1000 --throughput "700"

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Container name.

--partition-key-path -p

Partition Key Path, e.g., '/address/zipcode'.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--analytical-storage-ttl -t

Analytical TTL, when analytical storage is enabled.

--cep

Client Encryption Policy, you can enter it as a string or as a file, e.g., --cep @policy-file.json or --cep "{"includedPaths": [{"path": "/path1","clientEncryptionKeyId": "key1","encryptionAlgorithm": "AEAD_AES_256_CBC_HMAC_SHA256","encryptionType": "Deterministic"}],"policyFormatVersion": 2}".

--conflict-resolution-policy -c

Conflict Resolution Policy, you can enter it as a string or as a file, e.g., --conflict-resolution-policy @policy-file.json or --conflict-resolution-policy "{"mode": "lastWriterWins", "conflictResolutionPath": "/path"}".

--idx

Indexing Policy, you can enter it as a string or as a file, e.g., --idx @policy-file.json or --idx "{"indexingMode": "consistent", "automatic": true, "includedPaths": [{"path": "/*"}], "excludedPaths": [{ "path": "/headquarters/employees/?"}, { "path": "/"_etag"/?"}]}".

default value: { "indexingMode": "consistent", "automatic": true, "includedPaths": [ { "path": "/*" } ], "excludedPaths": [ { "path": "/\"_etag\"/?" } ] }
--max-throughput

The maximum throughput resource can scale to (RU/s). Provided when the resource is autoscale enabled. The minimum value can be 4000 (RU/s).

--partition-key-version

The version of partition key.

--throughput

The throughput of SQL container (RU/s). Default value is 400. Omit this parameter if the database has shared throughput unless the container should have dedicated throughput.

--ttl

Default TTL. If the value is missing or set to "-1", items don’t expire. If the value is set to "n", items will expire "n" seconds after last modified time.

--unique-key-policy -u

Unique Key Policy, you can enter it as a string or as a file, e.g., --unique-key-policy @policy-file.json or --unique-key-policy "{"uniqueKeys": [{"paths": ["/path/to/key1"]}, {"paths": ["/path/to/key2"]}]}".

az cosmosdb sql container delete

Delete the SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container delete --account-name
                                 --database-name
                                 --name
                                 --resource-group
                                 [--yes]

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Container name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--yes -y

Do not prompt for confirmation.

az cosmosdb sql container exists

Checks if an Azure Cosmos DB SQL container exists.

az cosmosdb sql container exists --account-name
                                 --database-name
                                 --name
                                 --resource-group

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Container name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az cosmosdb sql container list

List the SQL containers under an Azure Cosmos DB SQL database.

az cosmosdb sql container list --account-name
                               --database-name
                               --resource-group

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az cosmosdb sql container merge

Merges the partitions of a sql container.

az cosmosdb sql container merge --account-name
                                --database-name
                                --name
                                --resource-group

Examples

merge partitions of container my-container

az cosmosdb sql container merge -g my-resource-group -a my-account -d my-db --name my-container

Required Parameters

--account-name -a

Name of the CosmosDB database account.

--database-name -d

Name of the CosmosDB database name.

--name -n

Name of the CosmosDB collection.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az cosmosdb sql container redistribute-partition-throughput

Redistributes the partition throughput of a sql container.

az cosmosdb sql container redistribute-partition-throughput --account-name
                                                            --database-name
                                                            --name
                                                            --resource-group
                                                            [--evenly-distribute {false, true}]
                                                            [--source-partition-info]
                                                            [--target-partition-info]

Examples

Evenly distributes the partition throughput for a sql container among all physical partitions

az cosmosdb sql container redistribute-partition-throughput --account-name account_name --database-name db_name --name container_name  --resource-group rg_name --evenly-distribute

Redistributes the partition throughput for a sql container from source partitions to target partitions

az cosmosdb sql container redistribute-partition-throughput --account-name account_name --database-name db_name --name container_name  --resource-group rg_name --target-partition-info 8=1200 6=1200]' --source-partition-info 9]'

Required Parameters

--account-name -a

Name of the CosmosDB database account.

--database-name -d

Name of the CosmosDB database name.

--name -n

Name of the CosmosDB collection.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--evenly-distribute

Switch to distribute throughput equally among all physical partitions.

accepted values: false, true
--source-partition-info

Space separated source physical partition ids eg: 1 2.

--target-partition-info

Information about desired target physical partition throughput eg: 0=1200 1=1200.

az cosmosdb sql container restore

Restore a deleted sql container within the same account.

az cosmosdb sql container restore --account-name
                                  --database-name
                                  --name
                                  --resource-group
                                  --restore-timestamp

Examples

Restore a deleted sql container within the same account.

az cosmosdb sql container restore --resource-group resource_group --account-name database_account_name --database-name parent_database_name --name name_of_container_needs_to_be_restored --restore-timestamp 2020-07-13T16:03:41+0000

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Container name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

--restore-timestamp -t

The timestamp to which the container needs to be restored to.

az cosmosdb sql container retrieve-partition-throughput

Retrieve the partition throughput of a sql container.

az cosmosdb sql container retrieve-partition-throughput --account-name
                                                        --database-name
                                                        --name
                                                        --resource-group
                                                        [--all-partitions {false, true}]
                                                        [--physical-partition-ids]

Examples

Retrieve container container_name's throughput for specific physical partitions

az cosmosdb sql container retrieve-partition-throughput --account-name account_name --database-name db_name --name container_name  --resource-group rg_name --physical-partition-ids 8 9

Retrieve container container_name's throughput for all physical partitions

az cosmosdb sql container retrieve-partition-throughput --account-name account_name --database-name db_name --name container_name  --resource-group rg_name --all-partitions

Required Parameters

--account-name -a

Name of the CosmosDB database account.

--database-name -d

Name of the CosmosDB database name.

--name -n

Name of the CosmosDB container.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--all-partitions

Switch to retrieve throughput for all physical partitions.

accepted values: false, true
--physical-partition-ids -p

Space separated list of physical partition ids.

az cosmosdb sql container show

Show the details of a SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container show --account-name
                               --database-name
                               --name
                               --resource-group

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Container name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

az cosmosdb sql container update

Update an SQL container under an Azure Cosmos DB SQL database.

az cosmosdb sql container update --account-name
                                 --database-name
                                 --name
                                 --resource-group
                                 [--analytical-storage-ttl]
                                 [--idx]
                                 [--ttl]

Required Parameters

--account-name -a

Cosmosdb account name.

--database-name -d

Database name.

--name -n

Container name.

--resource-group -g

Name of resource group. You can configure the default group using az configure --defaults group=<name>.

Optional Parameters

--analytical-storage-ttl -t

Analytical TTL, when analytical storage is enabled.

--idx

Indexing Policy, you can enter it as a string or as a file, e.g., --idx @policy-file.json or --idx "{"indexingMode": "consistent", "automatic": true, "includedPaths": [{"path": "/*"}], "excludedPaths": [{ "path": "/headquarters/employees/?"}, { "path": "/"_etag"/?"}]}".

--ttl

Default TTL. If the value is missing or set to "-1", items don’t expire. If the value is set to "n", items will expire "n" seconds after last modified time.