使用 Microsoft.Azure.Storage (cosmosDB) 更新 table 对象失败
Update table objects using Microsoft.Azure.Storage (cosmosDB) fails
我无法使用 Microsoft.Azure.CosmosDB.Table 更新 table 对象并出现以下异常。 "Message: The requested resource is no longer available at the server."代码:消失
我可以 运行 毫无问题地选择。
使用命名空间Microsoft.WindowsAzure 我可以进行查询和更新。
此代码也适用于 devdb 存储
或者如果我将连接字符串更改为 Azure Table 存储。唯一不起作用的是指向 CosmosDb。
`
Microsoft.Azure.Storage;
using Microsoft.Azure.CosmosDB.Table;
namespace AzureTester
{
class Program
{
static void Main(string[] args)
{
//cosmosdb.azure these don't work for TableOperation.InsertOrMerge(x). They do for Selects
var connectionString = "........TableEndpoint=https://*****.table.cosmosdb.azure.com:443/;";
//table storage or dev this works for everything
//var connectionString = ".....EndpointSuffix=core.windows.net";
//var connectionString = "UseDevelopmentStorage=true;";
var storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("Boat");
TableQuery<Boat> query = new TableQuery<Boat>()
.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "jack"));
var returnedBoat = table.ExecuteQuerySegmentedAsync<Boat>(query, null).Result; //this always works.
Boat x = new Boat();
x.PartitionKey = "jack";
x.RowKey = "black";
x.Type = "dragon";
TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(x);
//hangs on this line when connection string is cosmosdb.azure.com
TableResult result = table.Execute(insertOrMergeOperation);
Boat inserted = result.Result as Boat;
}
当 Cosmos DB Table API 出来的时候,我认为他们使用了命名空间 Microsoft.Azure.Storage,但他们现在使用 Microsoft.Azure.CosmosDB.Table。此外,从您的代码中,不清楚您是要访问 Cosmos DB Tables 还是 Azure Storage Tables。如果要访问 Azure Storage Tables,则必须使用 WindowsAzure.Storage.* 程序集,您将访问存储帐户。
如果你想访问 CosmosDB Table 中的数据,你必须使用他们的 Table API,并且数据必须在 Cosmos DB 数据库中,而不是在 Azure 存储中。有关使用 .NET 访问 Cosmos DB 的示例 table,请参阅 Quickstart: Build a Table API app with .NET and Azure Cosmos DB。
尝试使用 Microsoft.Azure.Storage.Common
的 8.6.0 或 8.7.0 版本
卸载 Microsoft.Azure.CosmosDB.Table.1.1.0。然后卸载Microsoft.Azure.Storage.Common.9.0.0.1-preview。然后安装 Microsoft.Azure.Storage.Common.8.6.0-preview 或 Microsoft.Azure.Storage.Common.8.7.0.1-preview。然后最后安装 Microsoft.Azure.CosmosDB.Table.1.1.0.
失败是由我的本地 pc/network 上的某些东西引起的。我怀疑 McAfee Endpoint Security 与此类似 post:
相同的代码在我的家用电脑上运行良好。虽然我还没有确定确切的错误,但它可能是防病毒或防火墙保护。
我无法解释为什么 McAfee 允许 Microsoft.WindowsAzure 而不允许 Microsoft.Azure
我无法使用 Microsoft.Azure.CosmosDB.Table 更新 table 对象并出现以下异常。 "Message: The requested resource is no longer available at the server."代码:消失 我可以 运行 毫无问题地选择。
使用命名空间Microsoft.WindowsAzure 我可以进行查询和更新。 此代码也适用于 devdb 存储 或者如果我将连接字符串更改为 Azure Table 存储。唯一不起作用的是指向 CosmosDb。
`
Microsoft.Azure.Storage;
using Microsoft.Azure.CosmosDB.Table;
namespace AzureTester
{
class Program
{
static void Main(string[] args)
{
//cosmosdb.azure these don't work for TableOperation.InsertOrMerge(x). They do for Selects
var connectionString = "........TableEndpoint=https://*****.table.cosmosdb.azure.com:443/;";
//table storage or dev this works for everything
//var connectionString = ".....EndpointSuffix=core.windows.net";
//var connectionString = "UseDevelopmentStorage=true;";
var storageAccount = CloudStorageAccount.Parse(connectionString);
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
var table = tableClient.GetTableReference("Boat");
TableQuery<Boat> query = new TableQuery<Boat>()
.Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "jack"));
var returnedBoat = table.ExecuteQuerySegmentedAsync<Boat>(query, null).Result; //this always works.
Boat x = new Boat();
x.PartitionKey = "jack";
x.RowKey = "black";
x.Type = "dragon";
TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(x);
//hangs on this line when connection string is cosmosdb.azure.com
TableResult result = table.Execute(insertOrMergeOperation);
Boat inserted = result.Result as Boat;
}
当 Cosmos DB Table API 出来的时候,我认为他们使用了命名空间 Microsoft.Azure.Storage,但他们现在使用 Microsoft.Azure.CosmosDB.Table。此外,从您的代码中,不清楚您是要访问 Cosmos DB Tables 还是 Azure Storage Tables。如果要访问 Azure Storage Tables,则必须使用 WindowsAzure.Storage.* 程序集,您将访问存储帐户。
如果你想访问 CosmosDB Table 中的数据,你必须使用他们的 Table API,并且数据必须在 Cosmos DB 数据库中,而不是在 Azure 存储中。有关使用 .NET 访问 Cosmos DB 的示例 table,请参阅 Quickstart: Build a Table API app with .NET and Azure Cosmos DB。
尝试使用 Microsoft.Azure.Storage.Common
的 8.6.0 或 8.7.0 版本卸载 Microsoft.Azure.CosmosDB.Table.1.1.0。然后卸载Microsoft.Azure.Storage.Common.9.0.0.1-preview。然后安装 Microsoft.Azure.Storage.Common.8.6.0-preview 或 Microsoft.Azure.Storage.Common.8.7.0.1-preview。然后最后安装 Microsoft.Azure.CosmosDB.Table.1.1.0.
失败是由我的本地 pc/network 上的某些东西引起的。我怀疑 McAfee Endpoint Security 与此类似 post:
相同的代码在我的家用电脑上运行良好。虽然我还没有确定确切的错误,但它可能是防病毒或防火墙保护。
我无法解释为什么 McAfee 允许 Microsoft.WindowsAzure 而不允许 Microsoft.Azure