Note: This capability is now available to use by signing up for the Preview from the Azure Portal. Please refer to https://aka.ms/azurecosmosdb-containercopy to learn more. This repo is outdated and is not managed any longer.
You can perform offline container copy within an Azure Cosmos DB account using container copy jobs.
This functionality is currently available for Azure Cosmos DB Cassandra API and SQL API accounts.
If you have not signed-up for this Preview yet, please do so using this link.
You may need to copy data within your Azure Cosmos DB account if you want to achieve either of these scenarios:
- Copy all items from one container to another.
- Change the granularity at which throughput is provisioned - from database to container and vice-versa.
- Change the partition key of a container.
- Update the unique keys for a container.
- Rename a container/database.
- Adopt new features that are only supported on new containers.
- Create the target Cosmos DB container with the required settings (partition key, throughput granularity, RUs, unique key, etc.).
- Stop the operations on the source container by pausing the application instances or any clients connecting to it.
- Create the container copy job.
- Monitor the progress of the container copy job and wait until it's completed.
- Resume the operations by appropriately pointing the application or client to the source or target container copy as intended.
- Make sure you have Azure CLI downloaded and installed on your machine before trying out container copy.
- Currently, container copy is only supported in these regions. Make sure your account is in one of these regions.
- Download this code as a zip file.
- Unzip it.
- Open the folder in Azure Data Studio (File - Open Folder).
- Run the code cells from either the SQL container copy notebook or Cassandra copy container notebook.
- You may use the commands specified in the SQL container copy notebook or Cassandra copy container notebook to create and monitor container copy jobs through Azure CLI.
To learn more about intra-account container copy jobs, refer to this doc.