Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it OK to hold a reference to an Azure CloudTable for a long period of time?

I have a method that we call to get the reference to the CloudTable before I write or query table storage.

private static CloudTable GetCloudTable() {
   var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
   var tableClient = storageAccount.CreateCloudTableClient();
   var table = tableClient.GetTableReference("TheTableName");
   return table;
}

Is acceptable to put this in the constructor of my table handling class? Is it an additional overhead to run this code on every table insert? It seems to me that I am increasing the number of transactions that I am running.

like image 944
Aran Mulholland Avatar asked Mar 27 '14 02:03

Aran Mulholland


People also ask

What are the limitations of Azure tables?

Azure Storage Table was not created by God, it was created by folks like us (much smarter though). It has limitations on size of a single row (1 MB), size of a single column (64KB), number of columns per row (255) and so on.

What is the maximum amount of data that can be stored in a Azure table storage database?

An entity in Azure Storage can be up to 1MB in size. An entity in Azure Cosmos DB can be up to 2MB in size. Properties: A property is a name-value pair. Each entity can include up to 252 properties to store data.

What is the difference between Azure table storage and Cosmos DB?

Azure Table Storage supports a single region with an optional read-only secondary region for availability. Cosmos DB supports distribution from 1 to more than 30 regions with automatic failovers worldwide. You can easily manage this from the Azure portal and define the failover behavior.


1 Answers

Your code snippets does not make any message to be sent to the Storage Service. The actual message is sent only when you use the "table" variable to actually Create, Query, or perform any CRUD operation against the storage. So the answer to "am I increasing the number of transactions by running this code on every table insert?" is NO.

That said, CloudStorageAccount.Parse and CloudConfigurationManager.GetSetting (the first line in your code snippet) do create some overhead (string parsing and configuration item retrieving). So for sure I suggest you to perform them only once and then reuse their result in every table operation(yes, putting this in the constructor IS an option).

However, the CloudTableClient object returned by CreateCloudTableClient() is not guaranteed to be thread safe. So IF threading is a issue in your evnvironment (i.e. you are you are using the same instance of your class from multple threads), I suggest to create a new instance of CloudTableClient every time you need.

like image 106
Andrea Coluccio Avatar answered Oct 06 '22 00:10

Andrea Coluccio