Mark Powney
Mark Powney

Reputation: 21

How to Insert a Azure Storage TableEntity with property longer than 32kB

When I have a class inheriting from TableEntity with the following constructor:

public CacheEntity(string cacheType, string key, string value) {
    this.PartitionKey = cacheType;
    this.RowKey = key;
    this.Value = value;
}

And I execute an insert operation as follows - when postsData is more than 32768 characters long:

CacheEntity entity = new CacheEntity(CacheType.CategoryPosts, cacheKey, postsData.Substring(0, 32769));
TableOperation insertCacheOperation = TableOperation.Insert(entity);
await cacheTable.ExecuteAsync(insertCacheOperation);

The ExecuteAsync method returns with Bad Request.

TableStorage documentation states that the maximum size of a Row and Property is 1MiB

I can successfully perform ExecuteAsync by truncating postsData to 32768, e.g.

CacheEntity entity = new CacheEntity(CacheType.CategoryPosts, cacheKey, postsData.Substring(0, 32768));

Is there a simple fix to allow more than 32KB of data in a TableEntity property?

Upvotes: 1

Views: 456

Answers (1)

NotFound
NotFound

Reputation: 6157

There's a maximum size for all properties that you've found, but each property also has a max size. According to the documentation:

String values may be up to 64 KB in size. Note that the maximum number of characters supported is about 32 K or less.

Upvotes: 1

Related Questions