Storing a table does not mean relational database here.
Azure Storage can store
just a
table without any foreign keys or any other kind of relation. These tables are
highly
scalable and ideal for handling large amount of data. Tables can be stored and
queried for
large amount of data. The relational database can be stored using SQL Data
Services,
which is a separate service.
The three main parts of service are:
Tables
Entities
Properties
For example, if ‘Book’ is an entity, its properties will be Id, Title, Publisher,
Author etc.
Table will be created for a collection of entities. There can be 252 custom
properties and
3 system properties. An entity will always have system properties which are
PartitionKey,
RowKey and Timestamp. Timestamp is system generated but you will have to specify
the
PartitionKey and RowKey while inserting data into the table. The example below will
make
it clearer. Table name and Property name is case sensitive which should always be
considered while creating a table.
How to Manage Tables Using PowerShell
Step 1: Download and install Windows PowerShell as discussed previously in the
tutorial.
Step 2: Right-click on ‘Windows PowerShell’, choose ‘Pin to Taskbar’ to pin it on
the
taskbar of your computer.
Step 3: Choose ‘Run ISE as Administrator’.
Creating a Table
Step 1: Copy the following commands and paste into the screen. Replace the
highlighted
text with your account.
Step 2: Login into your account.
$StorageAccountName = "mystorageaccount"
$StorageAccountKey = "mystoragekey"
$Ctx = New-AzureStorageContext $StorageAccountName -StorageAccountKey
$StorageAccountKey
Step 3: Create a new table.
9. Tables Microsoft Azure
40
$tabName = "Mytablename"
New-AzureStorageTable –Name $tabName –Context $Ctx
The following image shows a table being created by the name of ‘book’.
You can see that it has given the following end point as a result.
https://tutorialspoint.table.core.windows.net/Book
Similarly, you can retrieve, delete and insert data into the table using preset
commands
in PowerShell.
Retrieve Table
$tabName = "Book"
Get-AzureStorageTable –Name $tabName –Context $Ctx
Delete Table
$tabName = "Book"
Remove-AzureStorageTable –Name $tabName –Context $Ct