Skip to content

Commit c95f5e3

Browse files
Merge pull request #226517 from seesharprun/cosmos-merge-code-samples
Cosmos DB | Update code samples in merge article
2 parents 09d58f4 + ee7a5cb commit c95f5e3

File tree

1 file changed

+74
-29
lines changed

1 file changed

+74
-29
lines changed

articles/cosmos-db/merge.md

Lines changed: 74 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
---
2-
title: Merge partitions in Azure Cosmos DB (preview)
3-
description: Learn more about the merge partitions capability in Azure Cosmos DB
2+
title: Merge partitions (preview)
3+
titleSuffix: Azure Cosmos DB
4+
description: Reduce the number of physical partitions used for your container with the merge capability in Azure Cosmos DB.
5+
ms.topic: conceptual
46
author: seesharprun
57
ms.author: sidandrews
8+
ms.reviewer: dech
69
ms.service: cosmos-db
10+
ms.date: 02/07/2023
711
ms.custom: event-tier1-build-2022, ignite-2022
8-
ms.topic: conceptual
9-
ms.reviewer: dech
10-
ms.date: 10/26/2022
1112
---
1213

1314
# Merge partitions in Azure Cosmos DB (preview)
@@ -70,13 +71,15 @@ Based on conditions 1 and 2, our container can potentially benefit from merging
7071
### Merging physical partitions
7172

7273
In PowerShell, when the flag `-WhatIf` is passed in, Azure Cosmos DB will run a simulation and return the expected result of the merge, but won't run the merge itself. When the flag isn't passed in, the merge will execute against the resource. When finished, the command will output the current amount of storage in KB per physical partition post-merge.
74+
7375
> [!TIP]
7476
> Before running a merge, it's recommended to set your provisioned RU/s (either manual RU/s or autoscale max RU/s) as close as possible to your desired steady state RU/s post-merge, to help ensure the system calculates an efficient partition layout.
7577
7678
#### [PowerShell](#tab/azure-powershell)
7779

78-
```azurepowershell
79-
// Add the preview extension
80+
Use [`Install-Module`](/powershell/module/powershellget/install-module) to install the [Az.CosmosDB](/powershell/module/az.cosmosdb/) module with pre-release features enabled.
81+
82+
```azurepowershell-interactive
8083
$parameters = @{
8184
Name = "Az.CosmosDB"
8285
AllowPrerelease = $true
@@ -85,8 +88,22 @@ $parameters = @{
8588
Install-Module @parameters
8689
```
8790

88-
```azurepowershell
89-
// API for NoSQL
91+
#### [Azure CLI](#tab/azure-cli)
92+
93+
Use [`az extension add`](/cli/azure/extension#az-extension-add) to install the [cosmosdb-preview](https://github.com/azure/azure-cli-extensions/tree/main/src/cosmosdb-preview) Azure CLI extension.
94+
95+
```azurecli-interactive
96+
az extension add \
97+
--name cosmosdb-preview
98+
```
99+
100+
---
101+
102+
#### [API for NoSQL](#tab/nosql/azure-powershell)
103+
104+
Use `Invoke-AzCosmosDBSqlContainerMerge` with the `-WhatIf` parameter to preview the merge without actually performing the operation.
105+
106+
```azurepowershell-interactive
90107
$parameters = @{
91108
ResourceGroupName = "<resource-group-name>"
92109
AccountName = "<cosmos-account-name>"
@@ -97,36 +114,62 @@ $parameters = @{
97114
Invoke-AzCosmosDBSqlContainerMerge @parameters
98115
```
99116

100-
```azurepowershell
101-
// API for MongoDB
117+
Start the merge by running the same command without the `-WhatIf` parameter.
118+
119+
```azurepowershell-interactive
102120
$parameters = @{
103121
ResourceGroupName = "<resource-group-name>"
104122
AccountName = "<cosmos-account-name>"
105123
DatabaseName = "<cosmos-database-name>"
106124
Name = "<cosmos-container-name>"
107-
WhatIf = $true
108125
}
109-
Invoke-AzCosmosDBMongoDBCollectionMerge @parameters
126+
Invoke-AzCosmosDBSqlContainerMerge @parameters
110127
```
111128

112-
#### [Azure CLI](#tab/azure-cli)
129+
#### [API for NoSQL](#tab/nosql/azure-cli)
113130

114-
```azurecli
115-
// Add the preview extension
116-
az extension add --name cosmosdb-preview
117-
```
131+
Start the merge by using [`az cosmosdb sql container merge`](/cli/azure/cosmosdb/sql/container#az-cosmosdb-sql-container-merge).
118132

119-
```azurecli
120-
// API for NoSQL
133+
```azurecli-interactive
121134
az cosmosdb sql container merge \
122135
--resource-group '<resource-group-name>' \
123136
--account-name '<cosmos-account-name>' \
124137
--database-name '<cosmos-database-name>' \
125138
--name '<cosmos-container-name>'
126139
```
127140

128-
```azurecli
129-
// API for MongoDB
141+
#### [API for MongoDB](#tab/mongodb/azure-powershell)
142+
143+
Use `Invoke-AzCosmosDBMongoDBCollectionMerge` with the `-WhatIf` parameter to preview the merge without actually performing the operation.
144+
145+
```azurepowershell-interactive
146+
$parameters = @{
147+
ResourceGroupName = "<resource-group-name>"
148+
AccountName = "<cosmos-account-name>"
149+
DatabaseName = "<cosmos-database-name>"
150+
Name = "<cosmos-container-name>"
151+
WhatIf = $true
152+
}
153+
Invoke-AzCosmosDBMongoDBCollectionMerge @parameters
154+
```
155+
156+
Start the merge by running the same command without the `-WhatIf` parameter.
157+
158+
```azurepowershell-interactive
159+
$parameters = @{
160+
ResourceGroupName = "<resource-group-name>"
161+
AccountName = "<cosmos-account-name>"
162+
DatabaseName = "<cosmos-database-name>"
163+
Name = "<cosmos-container-name>"
164+
}
165+
Invoke-AzCosmosDBMongoDBCollectionMerge @parameters
166+
```
167+
168+
#### [API for MongoDB](#tab/mongodb/azure-cli)
169+
170+
Start the merge by using [`az cosmosdb mongodb collection merge`](/cli/azure/cosmosdb/mongodb/collection#az-cosmosdb-mongodb-collection-merge).
171+
172+
```azurecli-interactive
130173
az cosmosdb mongodb collection merge \
131174
--resource-group '<resource-group-name>' \
132175
--account-name '<cosmos-account-name>' \
@@ -146,6 +189,8 @@ You can track whether merge is still in progress by checking the **Activity Log*
146189

147190
## Limitations
148191

192+
The following are limitations of the merge feature at this time.
193+
149194
### Preview eligibility criteria
150195

151196
To enroll in the preview, your Azure Cosmos DB account must meet all the following criteria:
@@ -202,15 +247,15 @@ Support for other SDKs is planned for the future.
202247

203248
If you enroll in the preview, the following connectors will fail.
204249

205-
- Azure Data Factory <sup>1</sup>
206-
- Azure Stream Analytics <sup>1</sup>
207-
- Logic Apps <sup>1</sup>
208-
- Azure Functions <sup>1</sup>
209-
- Azure Search <sup>1</sup>
210-
- Azure Cosmos DB Spark connector <sup>1</sup>
250+
- Azure Data Factory ¹
251+
- Azure Stream Analytics ¹
252+
- Logic Apps ¹
253+
- Azure Functions ¹
254+
- Azure Search ¹
255+
- Azure Cosmos DB Spark connector ¹
211256
- Any third party library or tool that has a dependency on an Azure Cosmos DB SDK that isn't .NET V3 SDK v3.27.0 or higher
212257

213-
<sup>1</sup> Support for these connectors is planned for the future.
258+
¹ Support for these connectors is planned for the future.
214259

215260
## Next steps
216261

0 commit comments

Comments
 (0)