AzCosmosDBCollection
Synopsis
Creates a new Azure Cosmos DB collection (container) within an existing database.
Syntax
New-AzCosmosDBCollection
    -ResourceGroupName <String>
    -AccountName <String>
    -DatabaseName <String>
    -Name <String>
    [-PartitionKeyPath <String>]
    [-Throughput <Int32>]
    [-IndexingPolicy <Hashtable>]
    [-DefaultTimeToLive <Int64>]
    [-Location <String>]
    [-WhatIf]
    [-Confirm]Parameters
| Parameter | Type | Required | Description | 
|---|---|---|---|
| -ResourceGroupName | String | Yes | Name of the resource group containing the Cosmos DB account. | 
| -AccountName | String | Yes | Name of the Cosmos DB account. | 
| -DatabaseName | String | Yes | Existing database where the collection will be created. | 
| -Name | String | Yes | Name of the new collection (container). | 
| -PartitionKeyPath | String | No | Path of the partition key (e.g., /myPartitionKey). | 
| -Throughput | Int32 | No | Provisioned throughput (RU/s). Default is 400. | 
| -IndexingPolicy | Hashtable | No | Custom indexing policy definition. | 
| -DefaultTimeToLive | Int64 | No | TTL in seconds for items; -1 disables TTL. | 
| -Location | String | No | Azure region for the collection (overrides account default). | 
| -WhatIf | SwitchParameter | No | Shows what would happen if the command runs. | 
| -Confirm | SwitchParameter | No | Prompts for confirmation before executing. | 
Examples
Example 1: Create a collection with default settings
New-AzCosmosDBCollection `
  -ResourceGroupName "MyResourceGroup" `
  -AccountName "mycosmosdbaccount" `
  -DatabaseName "myDatabase" `
  -Name "myContainer"Example 2: Create a collection with a custom partition key and throughput
New-AzCosmosDBCollection `
  -ResourceGroupName "RG1" `
  -AccountName "cosmosacct" `
  -DatabaseName "OrdersDB" `
  -Name "Orders" `
  -PartitionKeyPath "/orderId" `
  -Throughput 1000Example 3: Create a collection with TTL enabled (30 days)
New-AzCosmosDBCollection `
  -ResourceGroupName "RG1" `
  -AccountName "cosmosacct" `
  -DatabaseName "LogsDB" `
  -Name "AppLogs" `
  -PartitionKeyPath "/logType" `
  -DefaultTimeToLive 2592000