Azure Table storage is a data store you can use to store structured data in a non-relational way. Azure Table storage is easy to manage, and you can create multiple independent tables in a single storage account.
Latest posts by Baki Onur Okutucu (see all)

An Azure storage account is a widely used object in Azure that enables us to store data in different shapes. A simple storage account in Azure provides several features, such as Files, Containers, and Tables, each of which has a different purpose and different management method.

Azure Table storage features

Azure Table storage has the advantage that you can quickly store structured data without having to deal with the complexity of a relational database system. You can also create a huge number of independent entities in a single table. Entities represent rows in a table containing both system properties and user-defined properties like key-value pairs.

Azure Storage table structure

Azure Storage table structure

The maximum number of properties (columns) per entity (row) is 255, three of which are system properties: PartitionKey, RowKey, and Timestamp. As these come automatically by default, we can add up to 252 extra columns.

The partition key is a system property that identifies the partition in a specific table. We can have multiple rows with the same partition key. So this way, we can identify data groups in a table. This actually means that we can have different data sets in a single table with partition key support. A row key is also a system property in a table. Each row in a specific table must have a unique row key value. Unlike PartitionKey and RowKey, the Timestamp is a system-generated property that shows the row's creation time.

Multiple datasets in a single table

Multiple datasets in a single table

As shown in the above table, two data sets (sales and members) in the same table have no relation with each other. We can get the relevant data by specifying the correct partition key.

Creating Azure Storage tables

To be able to manage Azure Storage tables using PowerShell, you must install the required module first. To install the module, we can use the command below:

Install-Module AzureRmStorageTable

After creating a Table storage, the default address to access it is:

Now we can create a new storage account in which we will also create a new table. Use the following to create a new storage account:

$storageAccountName = "teststorageaccount000001"
$storageAccount = New-AzureRmStorageAccount -ResourceGroupName $resourceGroup `
  -Name $storageAccountName `
  -Location $location `
  -SkuName Standard_LRS `
  -Kind Storage

$context = $storageAccount.Context

After creating the storage account, we can create a new table in it with the command below:

$tableName = "testtable01"
New-AzureStorageTable –Name $tableName –Context $context
Creating a new Storage table

Creating a new Storage table

This created a new table. We can now add a few rows to the table using the commands below:

$storageTable = Get-AzureStorageTable -Name $tableName -Context $context

$partitionKey1 = "group1"
$partitionKey2 = "group2"

Add-azureStorageTableRow `
    -table $storageTable `
    -partitionKey $partitionKey1 `
    -rowKey ([guid]::NewGuid().tostring()) -property @{"name"="Onur";"age"=85}

Add-azureStorageTableRow `
    -table $storageTable `
    -partitionKey $partitionKey2 `
    -rowKey ([guid]::NewGuid().tostring()) -property @{"name"="Tuba";"age"=45}

Now we can list all rows and check how they appear in the table using the following command:

Get-AzureStorageTableRowAll -table $storageTable | ft
Listing Storage tables

Listing Storage tables

Filtering data

There are several ways to filter data in tables. Here are some useful examples to play with the data using some filtering methods:

Get-AzureStorageTableRowByPartitionKey -table $storageTable -partitionKey $partitionKey1 | ft

Get-AzureStorageTableRowByPartitionKey -table $storageTable -partitionKey $partitionKey2 | ft

Get-AzureStorageTableRowByCustomFilter `
    -table $storageTable `
    -customFilter "(age gt 50)"
Refining data using custom filters

Refining data using custom filters

Updating and deleting Table storage

To update an existing row, you can use the example below.

In this example, we first find the records (rows) with an age value below 50. Then we set the name values of those records as "Tuba-New." This updates the only record matching the filter with the new value.

$filter ="(age lt 50)"
$list = Get-AzureStorageTableRowByCustomFilter `
-table $storageTable `
-customFilter $filter

$ = "Tuba-New"
$list | Update-AzureStorageTableRow -table $storageTable

Get-AzureStorageTableRowAll -table $storageTable | ft
Updating an existing row

Updating an existing row

To remove all rows in a table, you need this command:

Get-AzureStorageTableRowAll -table $storageTable `
| Remove-AzureStorageTableRow -table $storageTable

And to delete the entire table, use this one:

Subscribe to 4sysops newsletter!

Remove-AzureStorageTable –Name $tableName –Context $ctx

As a simple NoSQL data source, Azure Storage tables are pretty useful to store non-relational data in an Azure storage account. You can easily manage the data in several ways, such as using Azure Portal, Azure Storage Explorer, and PowerShell.


Leave a reply

Your email address will not be published.


© 4sysops 2006 - 2023


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account