简体   繁体   English

使用Microsoft.Azure.Storage(cosmosDB)更新表对象失败

[英]Update table objects using Microsoft.Azure.Storage (cosmosDB) fails

I cannot update table objects using using Microsoft.Azure.CosmosDB.Table and get the following exception. 我无法使用Microsoft.Azure.CosmosDB.Table更新表对象,并得到以下异常。 "Message: The requested resource is no longer available at the server." “消息:请求的资源在服务器上不再可用。” Code: Gone I can run selects without issue. 代码:我可以运行选择了,没有问题。

Using namespace Microsoft.WindowsAzure I can do queries and updates. 使用命名空间Microsoft.WindowsAzure,我可以进行查询和更新。 Also this code works against devdb storage or if I change connection string to Azure Table storage. 同样,此代码也适用于devdb存储或如果我将连接字符串更改为Azure Table存储。 The only thing that does not work is pointing to CosmosDb. 唯一不起作用的是指向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;
    }

When Cosmos DB Table API came out, I think they used the namespace Microsoft.Azure.Storage, but they now use Microsoft.Azure.CosmosDB.Table. 当Cosmos DB Table API发布时,我认为他们使用了命名空间Microsoft.Azure.Storage,但现在使用的是Microsoft.Azure.CosmosDB.Table。 Also, from your code, it's not clear if you want to access Cosmos DB Tables or Azure Storage Tables. 另外,从代码中还不清楚您是否要访问Cosmos DB表或Azure存储表。 If you want to access Azure Storage Tables, you must use the WindowsAzure.Storage.* assemblies, and you will access the storage account. 如果要访问Azure存储表,则必须使用WindowsAzure.Storage。*程序集,然后才能访问存储帐户。

If you want to access the data in a CosmosDB Table, you have to use their Table API, and the data has to be in a Cosmos DB database, not in Azure Storage. 如果要访问CosmosDB表中的数据,则必须使用其表API,并且数据必须位于Cosmos DB数据库中,而不是Azure存储中。 For an example of using .NET to access a Cosmos DB table, see Quickstart: Build a Table API app with .NET and Azure Cosmos DB . 有关使用.NET访问Cosmos DB表的示例,请参见快速入门:使用.NET和Azure Cosmos DB构建Table API应用

Try using version 8.6.0 or 8.7.0 of Microsoft.Azure.Storage.Common 尝试使用Microsoft.Azure.Storage.Common的版本8.6.0或8.7.0

Uninstall Microsoft.Azure.CosmosDB.Table.1.1.0. 卸载Microsoft.Azure.CosmosDB.Table.1.1.0。 Then uninstall Microsoft.Azure.Storage.Common.9.0.0.1-preview. 然后卸载Microsoft.Azure.Storage.Common.9.0.0.1-preview。 Then install Microsoft.Azure.Storage.Common.8.6.0-preview or Microsoft.Azure.Storage.Common.8.7.0.1-preview. 然后安装Microsoft.Azure.Storage.Common.8.6.0-preview或Microsoft.Azure.Storage.Common.8.7.0.1-preview。 Then finally install Microsoft.Azure.CosmosDB.Table.1.1.0. 然后最终安装Microsoft.Azure.CosmosDB.Table.1.1.0。

The failure is caused by something on my local pc/network. 该故障是由我的本地PC /网络上的某物引起的。 I suspect McAfee Endpoint Security similar to this post: Azure DocumentDB sporadically throws SocketException / GoneException 我怀疑McAfee Endpoint Security与本文类似: Azure DocumentDB偶尔抛出SocketException / GoneException

The same code functions fine from my home PC. 在我的家用PC上,相同的代码功能正常。 Although I've not identified the exact fault its likely to be antivirus or firewall protection. 尽管我尚未确定确切的故障,但它可能是防病毒或防火墙保护。

I've no explanation as to why McAfee allows Microsoft.WindowsAzure and not Microsoft.Azure 对于McAfee为什么允许Microsoft.WindowsAzure而不允许Microsoft.Azure,我没有任何解释

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Azure Function csx 中使用 Microsoft.Azure.Storage - Use Microsoft.Azure.Storage in Azure Function csx 无法转换为microsoft.azure.cosmosDB.table.itableentity - cannot convert to microsoft.azure.cosmosDB.table.itableentity 我的 Microsoft Azure 表存储任务使用 .NET (C#) - My Microsoft Azure table storage task using .NET (C#) 安装Microsoft.Azure.CosmosDB.Table NuGet时出错 - Error installing Microsoft.Azure.CosmosDB.Table NuGet 使用Microsoft Bot Services在Azure表存储中添加属性 - Add property in azure table storage using Microsoft Bot Services 使用Microsoft.Azure.Storage.Common 9.4.0.2-preview测试Azure表存储 - Tests for Azure Table Storage using Microsoft.Azure.Storage.Common 9.4.0.2-preview 如果是全局复制,Microsoft.Azure.CosmosDB.Table是否会自动选择到cosmos DB的最低延迟路由? - Does Microsoft.Azure.CosmosDB.Table automatically choose the lowest latency route to the cosmos DB if replicated globally? Azure广告无法在microsoft.systemForCrossDomainIdentityManagement nuget程序包上使用补丁更新用户 - Azure Ad fails to update users using Patch on microsoft.systemForCrossDomainIdentityManagement nuget package 如何在Microsoft Azure表存储中批量获取表实体 - How to get a table entities as a batches in Microsoft Azure Table Storage 更新Azure表存储中的RowKey或PartitionKey - Update RowKey or PartitionKey in Azure Table Storage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM