Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to encode a URI to safely store in the RowKey of a TableServiceEntity?

I would really, really like to store a URI as the RowKey value in Azure Table storage. According to the documentation, RowKeys can't contain characters commonly found in URIs (/, \, #, ?).

The solution seems simple: Just encode the URI. But that doesn't work. For whatever reason, any values containing the sequence %2f (the encoded value for a forward-slash) can be inserted, but not queried even though '%2f' does not contain any forbidden characters.

Okay, so how about base64 encoding? Nope. It produces the occasional forward-slash character, which is not allowed.

So is there a method of encoding a string (a URI) that can be reliably stored as the RowKey in Azure Table? Preferably, but not necessarily, something human-readable.

like image 493
James Avatar asked Sep 21 '12 13:09

James


People also ask

What is partition key and RowKey in Azure Table Storage?

The row key is a unique identifier for an entity within a given partition. Together the PartitionKey and RowKey uniquely identify every entity within a table. The row key is a string value that may be up to 1 KiB in size. You must include the RowKey property in every insert, update, and delete operation.

Is Azure Table storage deprecated?

Azure table storage is being deprecated in favor of Azure Cosmos DB. Azure Cosmos DB offers many advantages over Azure table storage, such as: -Azure Cosmos DB is scalable.

What are the elements of an Azure Table storage key Table name and column name partition key and row key row number?

The key in an Azure Table Storage table comprises two elements. The partition key that identifies the partition containing the row, and a row key that is unique to each row in the same partition. Items in the same partition are stored in row key order. Rows that share the same partition key will be stored together.

What makes up an Azure Table storage key?

Each entity also has three system properties that specify a partition key, a row key, and a timestamp. Entities with the same partition key can be queried more quickly, and inserted/updated in atomic operations. An entity's row key is its unique identifier within a partition.


1 Answers

Replacing / with _ after using base64 encoding should work. Got this suggestion from Encoding and decoding a string that may have slashes in it

like image 199
user1036721 Avatar answered Jan 03 '23 02:01

user1036721