How to Change Azure Cosmos DB Partition Keys: Options, Tradeoffs Explained
Azure Cosmos DB does not allow changing a partition key in place once a container is created, making migration necessary when the original key causes performance issues like hot partitions or cross-partition queries. Developers have three main options to re-partition data into a new container: using the Azure portal's built-in Change Partition Key feature, running container copy jobs via Azure CLI, or performing a manual do-it-yourself migration. Each approach differs in the level of automation, control over cutover timing, and whether writes can continue during the copy process. Online copy mode allows writes to flow during migration but doubles RU charges on the source and requires specific account configurations, while offline mode halts writes before the job begins. For read-only scenarios where write patterns are unaffected, a Global Secondary Index can add an automatically synchronized, read-only container with a different partition key without moving or altering the source data.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in