Can i update RowKey or PartitionKey properties of entity in Azure Table Storage?
I thought yes or maybe just PartitionKey but now i am trying to do that(try to change RowKey or PartitionKey) and get error:
The remote server returned an error: (404) Not Found.
Description: An unhandled exception occurred during the execution of the current
web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.Net.WebException: The remote server returned an error:
(404) Not Found.
Source Error:
Line 143:
Line 144: var updateOperation = TableOperation.Replace(entity);
Line 145: _table.Execute(updateOperation);
Line 146: }
Line 147: }
var query = new TableQuery<CalculatorAccessTokenEntity>()
.Where(TableQuery.GenerateFilterCondition("AccessUrl",
QueryComparisons.Equal, url));
var newToken = GetUniqueKey(5);//get some random string of length 5
entity.PartitionKey = newToken;
// Try to use Merge here also but unsuccessful
var updateOperation = TableOperation.Replace(entity); _table.Execute(updateOperation);
The row key is a unique identifier for an entity within a given partition. Together the PartitionKey and RowKey uniquely identify every entity within a table. The row key is a string value that may be up to 1 KiB in size. You must include the RowKey property in every insert, update, and delete operation.
You can construct the Update Entity request as follows. HTTPS is recommended. Replace myaccount with the name of your storage account, and mytable with the name of your table. Replace myPartitionKey and myRowKey with the name of the partition key and row key that identify the entity to be updated.
How should you choose a good partition key for a Table storage implementation? (Choose all that apply.) They should always be unique, like a primary key in a SQL table. You should always use the same partition key for all records. Think about how you're likely to update the data using batch transactions.
Azure table storage is deprecated, but still in use by some organizations. Many organizations are still using Azure table storage because it is easy to use, and it has a lot of features. However, as Azure table storage becomes more difficult to use, organizations may want to look into alternatives, such as Cosmos DB.
No, you can't update an entity's PartitionKey
or RowKey
. What you would need to do is perform 2 operations: first delete the entity with existing PartitionKey/RowKey and then insert new entity with new PartitionKey/RowKey.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With