Creating and Managing Azure Storage Tables with PowerShell

Today’s mission was to get more familiar with Azure Storage Tables and to manage them with PowerShell. On GitHub I found the AzureTableEntity module from Tao Yang. Below are a number of code snippets I used to get my hands dirty with Azure Storage tables and the module.

Install the Module

Next we create an Azure Resource Group and an Azure Storage Account

We will need the Storage Account key later so let’s get that one as well.

Next we create a new Table with the name “Computerinventory”

Now that we have the table created, we can start adding data to it, let’s start with adding just one row first.

Let’s take a look what’s in the table now

 

image

Next let’s add some more data to it, the below code creates some random computer inventory data.

# Generate some demo data for PC inventory

 

# Add rows to Azure Storage Table

If all went fine, we should now have all the data in the table.

We now have 100 records in the table, with “11” computers located in Amsterdam

image

Now let’s look at Computer000001

image

It’s located in Amsterdam. Now let’s have a look at how to update a record, let’s say we want to change it to “Rotterdam”

Let’s retrieve the record again.

 

and there we go, it’s now registered in Rotterdam.

image

Let’s query the entire database again.

image

and finally, let’s remove the Computer000001

I query the information again, as i will re-use the return values to build the remove properties.

 

If you followed my example, you should now have 99 rows left.

I hope you enjoyed this blog post, as always comments and feedback are welcome.

Further reading and useful resources:

# https://docs.microsoft.com/en-us/rest/api/storageservices/querying-tables-and-entities
# https://blog.tyang.org/2016/11/30/powershell-module-for-managing-azure-table-storage-entities/
# https://www.powershellgallery.com/packages/AzureTableEntity/1.0.0.0
# https://github.com/tyconsulting/AzureTableEntity-PowerShell-Module
# https://docs.microsoft.com/en-us/rest/api/storageservices/designing-a-scalable-partitioning-strategy-for-azure-table-storage

Leave a Reply