Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
APPLIES TO:
NoSQL
MongoDB
Table
The Azure Cosmos DB desktop data migration 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:
Important
For this guide, you will perform a data migration from JSON to Azure Cosmos DB for NoSQL.
First, install the latest version of the desktop data migration tool from the GitHub repository.
Note
The desktop data migration tool requires .NET 6.0 or later on your local machine.
In your browser, navigate to the Releases section of the repository: azurecosmosdb/data-migration-desktop-tool/releases.
Download the latest compressed folder for your platform. There are compressed folders for the win-x64, mac-x64, and linux-x64 platforms.
Extract the files to an install location on your local machine.
(Optional) Add the desktop data migration tool to the PATH
environment variable of your local machine.
Next, create a target database and container on the Azure Cosmos DB for NoSQL account.
Open a new terminal. If you haven't already, sign in to the Azure CLI.
Create new shell variables for the Azure Cosmos DB account's name and resource group.
# Variable for Azure Cosmos DB account name
accountName="<name-of-existing-account>"
# Variable for resource group name
resourceGroupName="<name-of-existing-resource-group>"
Create a new database using az cosmosdb sql database create
. Name the new database cosmicworks
and configure the database with 400 RU/s of shared throughput.
az cosmosdb sql database create \
--resource-group $resourceGroupName \
--account-name $accountName \
--name cosmicworks \
--throughput 400
Use 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
.
az cosmosdb sql container create \
--resource-group $resourceGroupName \
--account-name $accountName \
--database-name cosmicworks \
--name products \
--partition-key-path "/category"
Find the primary connection string from the list of keys for the account with az cosmosdb keys list
.
az cosmosdb keys list \
--resource-group $resourceGroupName \
--name $accountName \
--type connection-strings
Record the primary connection string value. You use this credential later when migrating data with the tool.
Now, migrate data from a JSON array to the newly created Azure Cosmos DB for NoSQL container.
Navigate to an empty directory on your local machine. Within that directory, create a new file named migrationsettings.json.
Within the JSON file, create a new empty JSON object:
{}
Create a new property named Source
with the value json
. Create another new property named SourceSettings
with an empty object as the value.
{
"Source": "json",
"SourceSettings": {}
}
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.
{
"Source": "json",
"SourceSettings": {
"FilePath": "https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json"
}
}
Create another new property named Sink
with the value cosmos-nosql
. Also, create a property named SinkSettings
with an empty object.
{
"Source": "json",
"SourceSettings": {
"FilePath": "https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json"
},
"Sink": "cosmos-nosql",
"SinkSettings": {
}
}
Within SinkSettings
, create a property named ConnectionString
with the primary connection string you recorded earlier in this guide as its value.
{
"Source": "json",
"SourceSettings": {
"FilePath": "https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json"
},
"Sink": "cosmos-nosql",
"SinkSettings": {
"ConnectionString": "<connection-string-for-existing-account>"
}
}
Add Database
, Container
, and PartitionKeyPath
properties with cosmicworks
, products
, and /category
as their values respectively.
{
"Source": "json",
"SourceSettings": {
"FilePath": "https://raw.githubusercontent.com/azure-samples/cosmos-db-migration-sample-data/main/nosql-data.json"
},
"Sink": "cosmos-nosql",
"SinkSettings": {
"ConnectionString": "<connection-string-for-existing-account>",
"Database": "cosmicworks",
"Container": "products",
"PartitionKeyPath": "/category"
}
}
Save the migrationsettings.json file.
Open a new terminal and navigate to the directory containing your migrationsettings.json file.
Run the desktop data migration tool using the dmt
command.
dmt
Note
If you did not add the installation path to your PATH
environment variable, you may need to specify the full path to the dmt
executable.
The tool now outputs the sources and sinks used by the migration.
Using JSON Source
Using Cosmos-nosql Sink
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Migrate a MongoDB database to Azure Cosmos DB - Training
Online and offline migration option to Azure Cosmos DB API for MongoDB.
Certification
Microsoft Certified: Azure Cosmos DB Developer Specialty - Certifications
Write efficient queries, create indexing policies, manage, and provision resources in the SQL API and SDK with Microsoft Azure Cosmos DB.
Documentation
Use the Data Explorer to manage your data - Azure Cosmos DB
Learn about the Azure Cosmos DB Data Explorer, a standalone web-based interface that allows you to view and manage the data stored in Azure Cosmos DB.
Migrate hundreds of terabytes of data into Azure Cosmos DB
This doc describes how you can migrate 100s of terabytes of data into Azure Cosmos DB
An Introduction to the new Data Migration Tool for Azure Cosmos DB
With the original Azure Cosmos DB data migration tool becoming outdated and no longer able to support new features, a replacement application was needed to provide the same convenient and fast data transfer capabilities. The new modern tool built on cross-platform .NET 6 is now available for download, with out of the box support for Azure Cosmos DB, JSON, Mongo, Azure Table Storage, and SQL Server, as well as an extensible open-source architecture. Through example use cases I will demonstrate how to get sta