Azure Table and Queue Storage
Azure Table storage is used for storing a large amount of structured data. This service is a NoSQL data storage, which accepts authenticated calls from inside and outside of the Azure cloud. It is ideal for storing structured and non-relational data.
In case if you want to store relational data, then you should not use the Azure database. Unlike a relational database where the table has a fixed number of columns, and every row in the table should have those columns in the Azure table, which is a NoSQL data store. Each table can have entities, and each entity can have different properties. So generally, the schema will not be enforced on the objects that belong to a table.
Typical uses of Table storage include:
- Table storage is used for storing TBs of structured data capable of serving web-scale applications.
- It is used for storing datasets that don't require complex joins, foreign keys, or stored procedures and can be denormalized for fast access.
- It is used for quickly querying data using a clustered index.
- There are two ways of accessing data, one is using the OData protocol, and the other is LINQ queries with WCF Data Services with .NET Libraries.
Azure Table Structure
We need to create a storage account first because Azure table storage is offered under storage account, and then you have tables within that storage account. E.g., you can create employee table, address table, and each table will contain entities and entities will further include key-value pair like name email within an employee table.
However, one key difference here to the Azure table is the NoSQL data store and relational databases. These entities can have different schemas, so the first entity can have the name, email, and the second entity can have a name, email, and phone number also.
Azure table storage concepts
- Accounts: Every access to Azure storage service is done through a storage account, and all access to Azure Cosmos DB is done through a Table API account. So there are two types of tables Storage services available in Azure. The first one is Azure table storage, and the second one is a premium version, which is under Cosmos's DB. So if you are looking for a brilliant performance with low latency, then go for Cosmos's DB, particularly when you are dealing with mission-critical applications. In case if you can compromise on performance, but if you want to optimize the cost, then go for table storage.
- Table: It is a collection of entities. As we know, tables don't put a schema on entities that mean a single table can contain entities with different properties set.
- Entity: It is a set of properties, a similarly as database row. Azure Storage can be of 1MB in the size of the entity. But if we are using the premium version, which is Azure Cosmos DB, it can be of 2MB in size.
- Properties: It is a name-value pair where each entity can include up to 252 properties to store the data, and in addition to user properties, that means whatever the features you add. There are some system properties also that specify a partition key, a row key, and a timestamp. So every entity will have these three properties as a default. And when we are querying the data, we can carry the data based on the partition key and row key, and under the single partition, this row key should be unique. So when we query the data, we query the data with a partition key and row key. Generally, when we are fetching the entity from a single partition, it will be rapid because all the objects belong to a separate partition will be stored in one server in the background within Azure.
When you find a query, it needs to go to one server only to fetch the data, but if your query includes data that exists in 2-3 partitions, then the question used to go to multiple servers in the background, thereby the performance of the query will be impacted. So we need to keep that in mind when we are designing this table storage.
There are two access points
- Azure table storage: If we use Azure table storage then we can have http://<storageaccount>.table.core.windows.net/<table>
- Azure Cosmos DB Table API: If we use the premium version then we need to use http://<storageaccount>.table.cosmosdb.Azure.com/<table>
Table Storage queries
Queries retrieve the data from tables because a table only has one index. Query performance is usually related to the PartitionKey and RowKey properties.
Here is a sample query to retrieve data from the server:
<account>.windows.core.net/registrations(PartitionKey="2011 NewYork City Marathon_Full", RowKey="1234_Ankit_M_55")
Azure Queue Storage Service
It is a queue service, but there is a more advanced version of the queue service that is available in Azure, which is a service bus queue.
- It is a service for storing a large number of messages in the cloud that can be accessed from anywhere in the world using HTTP and HTTPS.
- A queue contains a set of message. Queue name must be all lowercase.
- A single queue message can be up to 64KB in size. A message can remain in the queue for a maximum time of 7 days
- URL format is http://<storage account>.queue.core.windows.net/<queue>
- When the message is retrieved from the queue, it stays invisible for 30 seconds. A message needs to be explicitly deleted from the queue to avoid getting picked up by another application.