Skip to content

Commit b9d7bef

Browse files
Merge pull request #4215 from MicrosoftDocs/main
Auto Publish – main to live - 2026-01-21 23:07 UTC
2 parents 558d813 + 67914e9 commit b9d7bef

1 file changed

Lines changed: 116 additions & 189 deletions

File tree

Lines changed: 116 additions & 189 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
---
2-
title: Migrate Data Using the Desktop Data Migration Tool
3-
description: Use the desktop data migration tool to migrate data from JSON, MongoDB, SQL Server, or Azure Table storage to Azure Cosmos DB.
2+
title: Migrate Data Using the Data Migration Tool
3+
description: Use the Azure Cosmos DB Data Migration Tool to migrate data from JSON, MongoDB, SQL Server, and many other databases and file formats to Azure Cosmos DB.
44
author: sandeepsnairms
55
ms.author: sandnair
66
ms.service: azure-cosmos-db
77
ms.subservice: nosql
88
ms.topic: how-to
9-
ms.date: 06/26/2025
9+
ms.date: 01/20/2026
1010
ms.custom: sfi-ropc-blocked
1111
# CustomerIntent: As a database owner, I want to use a tool to perform migration to Azure Cosmos DB so that I can streamline large and complex migrations.
1212
appliesto:
@@ -15,244 +15,171 @@ appliesto:
1515
- ✅ Table
1616
---
1717

18-
# Migrate data using the desktop data migration tool
18+
# Migrate data using the Data Migration Tool
1919

20-
The [Azure Cosmos DB desktop data migration tool](https://github.com/azurecosmosdb/data-migration-desktop-tool) is an open-source command-line application to import or export data from Azure Cosmos DB. The tool can migrate data to and from many sources and sinks including, but not limited to:
20+
The [Azure Cosmos DB Data Migration Tool](https://github.com/azurecosmosdb/data-migration-desktop-tool) is an open-source command-line application to import or export data from Azure Cosmos DB. The tool is built on an extension model for source and sink objects to migrate data.
2121

22-
- Azure Cosmos DB for NoSQL
23-
- Azure Cosmos DB for MongoDB
24-
- Azure Cosmos DB for Table
25-
- Azure Table storage
26-
- JSON
27-
- MongoDB
28-
- SQL Server
22+
## Supported extensions
2923

30-
> [!IMPORTANT]
31-
> For this guide, you perform a data migration from JSON to Azure Cosmos DB for NoSQL.
24+
- [Azure Cosmos DB for NoSQL](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/Cosmos/README.md)
25+
- [JSON](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/Json/README.md)
26+
- [MongoDB](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/Mongo/README.md)
27+
- [SQL Server](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/SqlServer/README.md)
28+
- [PostgreSQL](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/PostgreSQL/README.md)
29+
- [Azure Blob Storage](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/AzureBlob/README.md)
30+
- [Parquet](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/Parquet/README.md)
31+
- [CSV](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/Csv/README.md)
32+
- [AWS S3](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/AwsS3/README.md)
33+
- [Azure AI Search (Cognitive Search)](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/CognitiveSearch/README.md)
34+
- [Azure Cosmos DB for Table](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/Extensions/AzureTableAPI/README.md)
3235

3336
## Prerequisites
3437

3538
- An existing Azure Cosmos DB for NoSQL account.
3639
- If you have an Azure subscription, [create a new account](how-to-create-account.md?tabs=azure-portal).
3740
- If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn) before you begin.
38-
- Latest version of [Azure CLI](/cli/azure/install-azure-cli).
39-
- [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0) or later.
41+
- [.NET 8.0](https://dotnet.microsoft.com/download/dotnet/8.0) or later on your local machine.
42+
- Optional [Docker Desktop](https://docs.docker.com/get-started/get-docker/)
4043

41-
## Install the desktop data migration tool
44+
## Using the prebuilt Docker image
4245

43-
First, install the latest version of the desktop data migration tool from the GitHub repository.
46+
The easiest way to use the container is to pull the prebuilt image from Microsoft Container Registry. [Docker Desktop](https://docs.docker.com/get-started/get-docker/) is required.
4447

4548
> [!NOTE]
46-
> The desktop data migration tool requires [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0) or later on your local machine.
49+
> The Data Migration Tool can also be configured to run in any containerized environment or as part of a GitHub Action. See [Run in a Docker Container](https://github.com/AzureCosmosDB/data-migration-desktop-tool?tab=readme-ov-file#docker-container) for more details.
4750
48-
1. In your browser, navigate to the [**Releases** section of the repository](https://github.com/azurecosmosdb/data-migration-desktop-tool/releases).
49-
50-
1. Download the latest compressed folder for your platform. There are compressed folders for the **win-x64**, **mac-x64**, and **linux-x64** platforms.
51-
52-
1. Extract the files to an install location on your local machine.
53-
54-
1. (Optional) Add the desktop data migration tool to the `PATH` environment variable of your local machine.
51+
1. Pull the latest version of the container from the registry.
5552

56-
## Prepare your migration target
53+
```shell
54+
docker pull mcr.microsoft.com/azurecosmosdb/linux/azure-cosmos-dmt:latest
55+
```
5756

58-
Next, create a target database and container on the Azure Cosmos DB for NoSQL account.
57+
1. Configure the migration settings. See [Configure migration settings](#configure-migration-settings)
5958

60-
### [Azure CLI](#tab/azure-cli)
59+
```shell
60+
docker run -v $(pwd)/config:/config -v $(pwd)/data:/data mcr.microsoft.com/azurecosmosdb/linux/azure-cosmos-dmt:latest run --settings /config/migrationsettings.json
61+
```
6162

62-
1. Open a new terminal. If you haven't already, [sign in to the Azure CLI](/cli/azure/authenticate-azure-cli).
63+
## Using from command line
6364

64-
1. Create new shell variables for the Azure Cosmos DB account's name and resource group.
65+
1. In your browser, navigate to the [**Releases** section of the repository](https://github.com/azurecosmosdb/data-migration-desktop-tool/releases).
6566

66-
```azurecli-interactive
67-
# Variable for Azure Cosmos DB account name
68-
accountName="<name-of-existing-account>"
69-
70-
# Variable for resource group name
71-
resourceGroupName="<name-of-existing-resource-group>"
72-
```
67+
1. Download the latest compressed folder for your platform. There are compressed folders for win-x64, win-arm64, mac-x64, mac-arm64, linux-x64, and linux-arm64 platforms.
7368

74-
1. Create a new database using [`az cosmosdb sql database create`](/cli/azure/cosmosdb/sql/database#az-cosmosdb-sql-database-create). Name the new database `cosmicworks` and configure the database with 400 RU/s of shared throughput.
69+
1. Extract the files to an install location on your local machine.
7570

76-
```azurecli-interactive
77-
az cosmosdb sql database create \
78-
--resource-group $resourceGroupName \
79-
--account-name $accountName \
80-
--name cosmicworks \
81-
--throughput 400
82-
```
71+
1. (Optional) Add the Data Migration Tool to the `PATH` environment variable of your local machine.
8372

84-
1. Use [`az cosmosdb sql container create`](/cli/azure/cosmosdb/sql/container#az-cosmosdb-sql-container-create) to create a new container named `products` within the `cosmicworks` database. Set the partition key path of the new container to `/category`.
73+
1. Configure the migration settings. See [Configure migration settings](#configure-migration-settings)
8574

86-
```azurecli-interactive
87-
az cosmosdb sql container create \
88-
--resource-group $resourceGroupName \
89-
--account-name $accountName \
90-
--database-name cosmicworks \
91-
--name products \
92-
--partition-key-path "/category"
93-
```
75+
1. Run the Data Migration Tool using the `dmt` command from a terminal.
9476

95-
1. Find the *primary connection string* from the list of keys for the account with [`az cosmosdb keys list`](/cli/azure/cosmosdb/keys#az-cosmosdb-keys-list).
96-
97-
```azurecli-interactive
98-
az cosmosdb keys list \
99-
--resource-group $resourceGroupName \
100-
--name $accountName \
101-
--type connection-strings
77+
```terminal
78+
dmt
10279
```
10380
104-
1. Record the *primary connection string* value. You use this credential later when migrating data with the tool.
105-
106-
### [Azure PowerShell](#tab/azure-powershell)
107-
108-
1. Open a new terminal. If you haven't already, [sign in to the Azure CLI](/cli/azure/authenticate-azure-cli).
109-
110-
1. Create new variables for the Azure Cosmos DB account's name and resource group.
111-
112-
```azurepowershell-interactive
113-
# Variable for Azure Cosmos DB account name
114-
$ACCOUNT_NAME = "<name-of-existing-account>"
115-
116-
# Variable for resource group name
117-
$RESOURCE_GROUP_NAME = "<name-of-existing-resource-group>"
118-
```
81+
> [!NOTE]
82+
> If you didn't add the installation path to your `PATH` environment variable, you might need to specify the full path to the `dmt` executable.
11983
120-
1. Create a new database using [`New-AzCosmosDBSqlDatabase`](/powershell/module/az.cosmosdb/new-azcosmosdbsqldatabase). Name the new database `cosmicworks` and configure the database with 400 RU/s of shared throughput.
84+
1. The tool outputs the sources and sinks used by the migration.
12185
122-
```azurepowershell-interactive
123-
$parameters = @{
124-
ResourceGroupName = $RESOURCE_GROUP_NAME
125-
AccountName = $ACCOUNT_NAME
126-
Name = "cosmicworks"
127-
Throughput = 400
128-
}
129-
New-AzCosmosDBSqlDatabase @parameters
86+
```output
87+
Using JSON Source
88+
Using Cosmos-nosql Sink
13089
```
13190
132-
1. Use [`New-AzCosmosDBSqlContainer`](/powershell/module/az.cosmosdb/new-azcosmosdbsqlcontainer) to create a new container named `products` within the `cosmicworks` database. Set the partition key path of the new container to `/category`.
91+
## Configure migration settings
13392
134-
```azurepowershell-interactive
135-
$parameters = @{
136-
ResourceGroupName = $RESOURCE_GROUP_NAME
137-
AccountName = $ACCOUNT_NAME
138-
DatabaseName = "cosmicworks"
139-
Name = "products"
140-
PartitionKeyPath = "/category"
141-
PartitionKeyKind = "Hash"
142-
}
143-
New-AzCosmosDBSqlContainer @parameters
144-
```
93+
The Data Migration Tool uses a migrationsettings.json to define the source and sink settings for the data to be copied. See [Supported Extension](#supported-extensions) for details on each extensions migration settings.
14594
146-
1. Find the *primary connection string* from the list of keys for the account with [`Get-AzCosmosDBAccountKey`](/powershell/module/az.cosmosdb/get-azcosmosdbaccountkey).
95+
Here's an example for migrating a [sample JSON file](https://github.com/AzureCosmosDB/data-migration-desktop-tool/blob/main/data/sample-data.json) to the Cosmos DB emulator.
14796
148-
```azurepowershell-interactive
149-
$parameters = @{
150-
ResourceGroupName = $RESOURCE_GROUP_NAME
151-
Name = $ACCOUNT_NAME
152-
Type = "ConnectionStrings"
97+
```json
98+
{
99+
"Source": "JSON",
100+
"Sink": "Cosmos-nosql",
101+
"SourceSettings": {
102+
"FilePath": "C:\\dmt\\data\\simple_json.json"
103+
},
104+
"SinkSettings": {
105+
"ConnectionString": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDj...",
106+
"Database": "datamigration",
107+
"Container": "sample",
108+
"PartitionKeyPath": "/id",
109+
"RecreateContainer": false,
110+
"IncludeMetadataFields": false
153111
}
154-
Get-AzCosmosDBAccountKey @parameters
155-
```
156-
157-
1. Record the *primary connection string* value. You use this credential later when migrating data with the tool.
112+
}
113+
```
158114

159-
---
160-
161-
## Perform a migration operation
162-
163-
Now, migrate data from a JSON array to the newly created Azure Cosmos DB for NoSQL container.
115+
### Migrate multiple sources
164116

165-
1. Navigate to an empty directory on your local machine. Within that directory, create a new file named *migrationsettings.json*.
117+
The migrationsettings.json can also be configured to execute multiple data transfer operations with a single run command with an *Operations* property consisting of an array of objects that include SourceSettings and SinkSettings for the extensions referenced in the *Source* and *Sink* properties.
166118

167-
1. Within the JSON file, create a new empty JSON object:
168-
169-
```json
170-
{}
171-
```
119+
Here's an example:
172120

173-
1. Create a new property named `Source` with the value `json`. Create another new property named `SourceSettings` with an empty object as the value.
174-
175-
```json
121+
```json
122+
{
123+
"Source": "json",
124+
"Sink": "cosmos-nosql",
125+
"SinkSettings": {
126+
"ConnectionString": "AccountEndpoint=https://localhost:8081/;AccountKey=C2y6yDj..."
127+
},
128+
"Operations": [
176129
{
177-
"Source": "json",
178-
"SourceSettings": {}
179-
}
180-
```
181-
182-
1. Within the `SourceSettings` object, create a new property named `FilePath` with the value set to this URI: [https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json](https://github.com/azure-samples/cosmos-db-migration-sample-data/blob/main/nosql-data.json).
183-
184-
```json
185-
{
186-
"Source": "json",
187-
"SourceSettings": {
188-
"FilePath": "https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json"
189-
}
190-
}
191-
```
192-
193-
1. Create another new property named `Sink` with the value `cosmos-nosql`. Also, create a property named `SinkSettings` with an empty object.
194-
195-
```json
196-
{
197-
"Source": "json",
198130
"SourceSettings": {
199-
"FilePath": "https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json"
131+
"FilePath": "products.json"
200132
},
201-
"Sink": "cosmos-nosql",
202133
"SinkSettings": {
134+
"Database": "ShoppingCartDB",
135+
"Container": "products",
136+
"PartitionKeyPath": "/categoryId"
203137
}
204-
}
205-
```
206-
207-
1. Within `SinkSettings`, create a property named `ConnectionString` with the *primary connection string* you recorded earlier in this guide as its value.
208-
209-
```json
138+
},
210139
{
211-
"Source": "json",
212140
"SourceSettings": {
213-
"FilePath": "https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json"
141+
"FilePath": "customers.json"
214142
},
215-
"Sink": "cosmos-nosql",
216143
"SinkSettings": {
217-
"ConnectionString": "<connection-string-for-existing-account>"
144+
"Database": "ShoppingCartDB",
145+
"Container": "customers",
146+
"PartitionKeyPath": "/customerId"
218147
}
219-
}
220-
```
221-
222-
1. Add `Database`, `Container`, and `PartitionKeyPath` properties with `cosmicworks`, `products`, and `/category` as their values respectively.
223-
224-
```json
148+
},
225149
{
226-
"Source": "json",
227150
"SourceSettings": {
228-
"FilePath": "https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json"
151+
"FilePath": "orders.json"
229152
},
230-
"Sink": "cosmos-nosql",
231153
"SinkSettings": {
232-
"ConnectionString": "<connection-string-for-existing-account>",
233-
"Database": "cosmicworks",
234-
"Container": "products",
235-
"PartitionKeyPath": "/category"
154+
"Database": "ShoppingCartDB",
155+
"Container": "customers",
156+
"PartitionKeyPath": "/customerId"
236157
}
237158
}
238-
```
239-
240-
1. **Save** the *migrationsettings.json* file.
241-
242-
1. Open a new terminal and navigate to the directory containing your *migrationsettings.json* file.
243-
244-
1. Run the desktop data migration tool using the `dmt` command.
245-
246-
```terminal
247-
dmt
248-
```
249-
250-
> [!NOTE]
251-
> If you didn't add the installation path to your `PATH` environment variable, you might need to specify the full path to the `dmt` executable.
252-
253-
1. The tool now outputs the sources and sinks used by the migration.
254-
255-
```output
256-
Using JSON Source
257-
Using Cosmos-nosql Sink
258-
```
159+
]
160+
}
161+
```
162+
163+
### Query support
164+
165+
Some extensions have support for queries as well on the source settings. See the documentation for each extension for details.
166+
167+
Here's an example:
168+
169+
```json
170+
{
171+
"Source": "cosmos-nosql",
172+
"Sink": "cosmos-nosql",
173+
"SourceSettings": {
174+
"ConnectionString": "AccountEndpoint=https://...",
175+
"Database": "ShoppingCartDB",
176+
"Container": "customers",
177+
"Query": "SELECT * FROM c WHERE c.type='order'"
178+
},
179+
"SinkSettings": {
180+
"ConnectionString": "AccountEndpoint=https://...",
181+
"Database": "orders",
182+
"PartitionKeyPath": "/customerId"
183+
}
184+
}
185+
```

0 commit comments

Comments
 (0)