Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does PartitionKey and RowKey in Azure Table Storage have to be string?

I suspect so, as the abstract class TableServiceEntity have the following:

    public virtual string PartitionKey { get; set; }
    public virtual string RowKey { get; set; }

What if I want a RowKey that is a DateTime or a Double?

like image 887
please delete me Avatar asked Mar 21 '11 04:03

please delete me


People also ask

What is PartitionKey and RowKey in Azure Table?

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.

What type of data does Azure Table storage store?

Azure Table storage is a service that stores non-relational structured data (also known as structured NoSQL data) in the cloud, providing a key/attribute store with a schemaless design. Because Table storage is schemaless, it's easy to adapt your data as the needs of your application evolve.

Which three of the following are required properties for an Azure Table entry?

PartitionKey, RowKey, Timestamp. These three properties are required for each Azure table entry.

How should you choose a good partition key for a Table storage implementation?

How should you choose a good partition key for a Table storage implementation? (Choose all that apply.) They should always be unique, like a primary key in a SQL table. You should always use the same partition key for all records. Think about how you're likely to update the data using batch transactions.


1 Answers

yes, these are both strings.

If you want the RowKey to be a DateTime or a Double then you must use a string representation.

There are a few common patterns for this. For DateTime, it's common to see the DateTime represented using a string that is conveniently sorted:

  • DateTime.Ticks.ToString("d19")

or

  • (DateTime.MaxValue.Ticks - DateTime.Ticks).ToString("d19")

See this blog post from Steve Marx - http://blog.smarx.com/posts/using-numbers-as-keys-in-windows-azure

like image 124
Stuart Avatar answered Oct 11 '22 10:10

Stuart