C# 更新Azure表存储中的RowKey或PartitionKey

C# 更新Azure表存储中的RowKey或PartitionKey,c#,azure,http-status-code-404,azure-table-storage,C#,Azure,Http Status Code 404,Azure Table Storage,我可以更新Azure表存储中实体的RowKey或PartitionKey属性吗 我想是或者可能只是PartitionKey,但现在我正在尝试这样做(尝试更改RowKey或PartitionKey)并得到错误: The remote server returned an error: (404) Not Found. Description: An unhandled exception occurred during the execution of the current

我可以更新Azure表存储中实体的RowKey或PartitionKey属性吗

我想是或者可能只是PartitionKey,但现在我正在尝试这样做(尝试更改RowKey或PartitionKey)并得到错误:

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()
.Where(TableQuery.GenerateFilterCondition(“AccessUrl”),
QueryComparisons.Equal,url));
var newToken=GetUniqueKey(5)//获取一些长度为5的随机字符串
entity.PartitionKey=newToken;
//也尝试在此处使用“合并”,但未成功
var updateOperation=TableOperation.Replace(实体)_表。执行(更新操作);

不,您不能更新实体的
分区键
行键
。您需要做的是执行2个操作:首先删除具有现有PartitionKey/RowKey的实体,然后插入具有新PartitionKey/RowKey的新实体。

是的,您是wright,因为这就像实体的唯一键。还有一个问题:我是否可以删除并插入操作“union”来执行此代码
\u表。执行(操作)
仅一次?不,它们必须是两个独立的操作。但是,如果PartitionKey没有更改,则可以使用实体批处理事务。这样,您就可以确保这两种操作要么成功,要么失败。
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);