Mark13426
Mark13426

Reputation: 2639

How do we validate uniqueness on an Azure Table Storage column?

The only primary key / uniqueness validation enforced by Azure Table Storage is partition key + row key. If I want any other column to be unique, I need to check this condition at the application layer.

if(service.GetEmailAddress(emailAddress) == null) {
   // email address is not yet registered by a user
   // persist user data to the database
}
else
{
   // display an error message
}

What I'm curious about is what happens if there are an X number of concurrent users that are trying to save the same column value to the same table. What's the safe way to make sure no duplicate values are entered below a specific column that does not have a UNIQUE constraint?

Upvotes: 2

Views: 1578

Answers (1)

Geethanga
Geethanga

Reputation: 1846

As far as I see Azure Table Storage is not designed for such purpose. As they say the goal of Azure Table Storage is to :

Storing Data for Efficient Retrieval and Persistence

So given that I think this may be not the solution you are looking for, I think you should evaluate the possibility of moving your data Azure SQL. Because in Azure Table Storage (Or any other NoSQL implementation) the concept of COLUMN doesn't have a much value, since you are allowed to save entities of different types in the same table.

Further reading link1, link2.

Upvotes: 2

Related Questions