Azure / azure-cosmos-table-dotnet

.NET SDK for Azure Cosmos Table API
14 stars 5 forks source link

Can't call CreateIfNotExists() on CloudTable with serverless offering #71

Closed DannyvanderKraan closed 3 years ago

DannyvanderKraan commented 3 years ago

SDK version Microsoft.Azure.Cosmos.Table 1.0.7

Issue reproduce steps I am using CosmosDB with Table API and serverless offering. I try to call CreateIfNotExists() on CloudTable. If fails with the following exception:

[2021-04-23T14:11:34.163Z] Executed 'HandleAddressChanged' (Failed, Id=6b4c570a-3d23-4dd8-9643-58893e368efb, Duration=20123ms) [2021-04-23T14:11:34.164Z] System.Private.CoreLib: Exception while executing function: HandleAddressChanged. Microsoft.Azure.Cosmos.Table: Reading or replacing offers is not supported for serverless accounts. [2021-04-23T14:11:34.166Z] ActivityId: 5b25d4ae-e6e8-4e44-92ca-1154dc207193, Microsoft.Azure.Documents.Common/2.11.0, Windows/10.0.18363 documentdb-netcore-sdk/2.10.0. Microsoft.Azure.DocumentDB.Core: Reading or replacing offers is not supported for serverless accounts. [2021-04-23T14:11:34.170Z] ActivityId: 5b25d4ae-e6e8-4e44-92ca-1154dc207193, Microsoft.Azure.Documents.Common/2.11.0, Windows/10.0.18363 documentdb-netcore-sdk/2.10.0.

On a CosmosDB TableAPI with fixed throughput this is not a problem. Does anyone know what is going on? Thank you in advance.

Environment Summary Cosmos DB Table API with serverless offering

sakash279 commented 3 years ago

Serverless table creation with the .NET Tables SDK works in REST mode only. You need to :

TableClientConfiguration config = new TableClientConfiguration();
config.UseRestExecutorForCosmosEndpoint = true; CloudTableClient tableClient = storageAccount.CreateCloudTableClient(config); Console.WriteLine("Create a Table for the demo");

// Create a table client for interacting with the table service CloudTable table = tableClient.GetTableReference(tableName);

if (table.CreateIfNotExists()) { Console.WriteLine("Created Table named: {0}", tableName); } else { Console.WriteLine("Table {0} already exists", tableName); }

DannyvanderKraan commented 3 years ago

@sakash279 Tested this and this works. Thank you. But how should I see this? As a workaround for the time being? Thank you.

sakash279 commented 3 years ago

The long term goal is to only support REST mode for CosmosDB service, and transition to Azure.Data.Tables SDK : https://github.com/Azure/azure-sdk-for-net/tree/master/sdk/tables/Azure.Data.Tables

If the switch to the other SDK is not possible, Microsoft.Azure.Cosmos.Table SDK is fine to use for now. We would suggest using REST mode for your application.

However, if you run into issues in REST mode, then file an issue here with us, and use this approach as a workaround.

DannyvanderKraan commented 3 years ago

Azure.Data.Tables is certainly possible for us. In fact, it performs better in my little tests than Cosmos.Table. So we'll be switching SDK. Thank you very much for the information. I didn't know about Azure.Data.Tables.

sakash279 commented 3 years ago

Thanks @DannyvanderKraan for letting us know. Is it possible to share any perf comparison results you might have done so far between the SDKs over here, so we can use it as a baseline for comparison for the SDKs?

In addition, issues on Azure.Data.Tables can be filed on the same repo, and will be picked up by the corresponding team.

I am going to close this issue, as you have a better solution now :)