You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
4
6
author: seesharprun
5
7
ms.author: sidandrews
8
+
ms.reviewer: dech
6
9
ms.service: cosmos-db
10
+
ms.date: 02/07/2023
7
11
ms.custom: event-tier1-build-2022, ignite-2022
8
-
ms.topic: conceptual
9
-
ms.reviewer: dech
10
-
ms.date: 10/26/2022
11
12
---
12
13
13
14
# Merge partitions in Azure Cosmos DB (preview)
@@ -70,69 +71,111 @@ Based on conditions 1 and 2, our container can potentially benefit from merging
70
71
### Merging physical partitions
71
72
72
73
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
+
73
75
> [!TIP]
74
76
> 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.
1. First, 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
83
+
$parameters = @{
84
+
Name = "Az.CosmosDB"
85
+
AllowPrerelease = $true
86
+
Force = $true
87
+
}
88
+
Install-Module @parameters
89
+
```
90
+
91
+
##### [API for NoSQL](#tab/azure-powershell/nosql)
92
+
93
+
1. Next, use `Invoke-AzCosmosDBSqlContainerMerge` with the `-WhatIf` parameter to preview the merge without actually performing the operation.
94
+
95
+
```azurepowershell-interactive
96
+
$parameters = @{
97
+
ResourceGroupName = "<resource-group-name>"
98
+
AccountName = "<cosmos-account-name>"
99
+
DatabaseName = "<cosmos-database-name>"
100
+
Name = "<cosmos-container-name>"
101
+
WhatIf = $true
102
+
}
103
+
Invoke-AzCosmosDBSqlContainerMerge @parameters
104
+
```
105
+
106
+
1. Finally, start the merge by running the same command without the `-WhatIf` parameter.
107
+
108
+
```azurepowershell-interactive
109
+
$parameters = @{
110
+
ResourceGroupName = "<resource-group-name>"
111
+
AccountName = "<cosmos-account-name>"
112
+
DatabaseName = "<cosmos-database-name>"
113
+
Name = "<cosmos-container-name>"
114
+
}
115
+
Invoke-AzCosmosDBSqlContainerMerge @parameters
116
+
```
117
+
118
+
##### [API for MongoDB](#tab/azure-powershell/mongodb)
119
+
120
+
1. Next, use `Invoke-AzCosmosDBMongoDBCollectionMerge` with the `-WhatIf` parameter to preview the merge without actually performing the operation.
1. First, 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.
150
+
151
+
```azurecli-interactive
152
+
az extension add \
153
+
--name cosmosdb-preview
154
+
```
155
+
156
+
##### [API for NoSQL](#tab/azure-cli/nosql)
157
+
158
+
1. Now, start the merge by using [`az cosmosdb sql container merge`](/cli/azure/cosmosdb/sql/container#az-cosmosdb-sql-container-merge).
159
+
160
+
```azurecli-interactive
161
+
az cosmosdb sql container merge \
162
+
--resource-group '<resource-group-name>' \
163
+
--account-name '<cosmos-account-name>' \
164
+
--database-name '<cosmos-database-name>' \
165
+
--name '<cosmos-container-name>'
166
+
```
167
+
168
+
##### [API for MongoDB](#tab/azure-cli/mongodb)
169
+
170
+
1. Now, start the merge by using [`az cosmosdb mongodb collection merge`](/cli/azure/cosmosdb/mongodb/collection#az-cosmosdb-mongodb-collection-merge).
171
+
172
+
```azurecli-interactive
173
+
az cosmosdb mongodb collection merge \
174
+
--resource-group '<resource-group-name>' \
175
+
--account-name '<cosmos-account-name>' \
176
+
--database-name '<cosmos-database-name>' \
177
+
--name '<cosmos-collection-name>'
178
+
```
136
179
137
180
---
138
181
@@ -146,6 +189,8 @@ You can track whether merge is still in progress by checking the **Activity Log*
146
189
147
190
## Limitations
148
191
192
+
The following are limitations of the merge feature at this time.
193
+
149
194
### Preview eligibility criteria
150
195
151
196
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.
202
247
203
248
If you enroll in the preview, the following connectors will fail.
204
249
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 ¹
211
256
- 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
212
257
213
-
<sup>1</sup> Support for these connectors is planned for the future.
258
+
¹ Support for these connectors is planned for the future.
0 commit comments