Changing partition key in Windows Azure Table Storage
You might have faced a situation where you have defined your partition key logic initially and due to some reasons you need to change your partition logic to something else.
Read on to know how you are going to handle such situations.
I have an application for which the Partition Key has been defined as the names of all the months.
PartitionKey = "January";
PartitionKey = "February";
---
PartitionKey = "December";
Now, I want to change the partition key logic. I want to change the partition to something like - "January2011", "January2012" etc.
Changing partition key is not possible in Windows Azure.
The only possible way is to delete and add the existing entity with a new partition logic.
Table.DeleteObject(entity);
Table.SaveChanges();
entity.PartitionKey = new PartitionKey();
Table.AddObject("entity", entity);
Table.SaveChanges();
One possible reason for not being able to change the partition key is that all the entities with same partition key are clustered together and now if we change the partition logic then all the clusters must be reconfigured.
Reference: http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/8f609080-eac1-4e4c-99c3-4bb9e6d76c9d


