0

I cannot update table objects using using Microsoft.Azure.CosmosDB.Table and get the following exception. "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. Also this code works against devdb storage or if I change connection string to Azure Table storage. The only thing that does not work is pointing to 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;
    }
1
  • Just discovered that when I point at emulator the code works. But when pointed at Azure I can select but I cannot update. value="UseDevelopmentStorage=true;" /> Commented Feb 14, 2018 at 21:05

3 Answers 3

1

When Cosmos DB Table API came out, I think they used the namespace Microsoft.Azure.Storage, but they now use Microsoft.Azure.CosmosDB.Table. Also, from your code, it's not clear if you want to access Cosmos DB Tables or Azure Storage Tables. If you want to access Azure Storage Tables, you must use the WindowsAzure.Storage.* assemblies, and you will access the storage account.

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. 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.

Sign up to request clarification or add additional context in comments.

6 Comments

Hi, Thanks for your help. I want to use Cosmos DB Tables but it throws the exception above on update. Select operations work fine. After trying loads of different things I changed namespace to WindowsAzure.Storage.* and both selects and updates work fine even though I still point to cosmos url. I followed the tutorial you mentioned and the code above comes directly from that git location. But it does not work.
I added the full exception I receive when I try use Microsoft.Azure.CosmosDB.Table. I can select from this table without issue using either of the ExcecuteQuery methods.
Also CloudStorageAccount is in namespace Microsoft.Azure.Storage
Actually Microsoft.Azure.CosmosDB.Table can access BOTH Azure Cosmos DB Table API AND Azure Table storage. You don't need another namespace for Azure Table storage. The SDK supports both.
Thanks Yaron .. unfortunately it works for neither for me. I tried the sample that robin suggested today again but it has the exact same issue. Just hangs and says resource no longer available.
|
1

Try using version 8.6.0 or 8.7.0 of Microsoft.Azure.Storage.Common

Uninstall Microsoft.Azure.CosmosDB.Table.1.1.0. Then uninstall 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. Then finally install Microsoft.Azure.CosmosDB.Table.1.1.0.

7 Comments

microsoft.azure.cosmosdb.table says these are the dependent assemblies. I'll give it a try anyway. But you are right.. I don't see why it should be dependent on a preview dll Microsoft.Azure.Storage.Common (>= 8.6.0-preview)
I got this error Severity Code Description Project File Line Suppression State Error Unable to uninstall 'Microsoft.Azure.Storage.Common.9.0.0.1-preview' because 'Microsoft.Azure.CosmosDB.Table.1.1.0' depends on it. 0 Also I can't find anything but previews for Microsoft.Azure.Storage.Common.. I wounder is there something wrong with my nuget feed.
Looking in detail at the package nuspec ..... <dependencies> <group targetFramework=".NETFramework4.5"> <dependency id="Microsoft.Azure.Storage.Common" version="8.6.0-preview" /> <dependency id="Microsoft.Azure.DocumentDB" version="1.19.0" /> <dependency id="Microsoft.Azure.KeyVault.Core" version="1.0.0" />....
Where are you supposed to find an non preview version of this? Microsoft.Azure.Storage.Common Thanks for the help.
Uninstall Microsoft.Azure.CosmosDB.Table.1.1.0. Then uninstall 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. Then finally install Microsoft.Azure.CosmosDB.Table.1.1.0.
|
1

The failure is caused by something on my local pc/network. I suspect McAfee Endpoint Security similar to this post: Azure DocumentDB sporadically throws SocketException / GoneException

The same code functions fine from my home 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

1 Comment

I have similar issues, I can never get anything to work with CosmosDb from inside my company's network on any machine or VM, but it works fine from my home PC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.