October 24, 2020

How to Use Azure Storage Accounts: Blobs, Files, Tables, and Queues

https://www.cloudsavvyit.com/7033/how-to-use-azure-storage-accounts-blobs-files-tables-and-queues/

azure logo

There are many ways to store data in Azure, but utilizing Storage Accounts to consolidate the management of Blobs (containers), File Shares, Tables, and Queues makes for easy and efficient management of some of the most useful file storage methods. Out of the four available options, when would you use each of these methods?

  • Blobs (Containers): Unstructured object storage medium best used for cloud-native workloads.
  • File Shares: Traditional Windows SMB file shares accessible over SMB 3.0.
  • Tables: A NoSQL key-value store typically used for rapid development.
  • Queues: Asynchronous message queueing for communication between application components.

Each of these technologies has many options and their own unique configurations, but in this article we are going to demonstrate how to simply manage data within each of these options.

Create a Storage Account

Before we can provision any of the above options, we need to first create a Storage account to hold the storage mediums. Navigate to Storage accounts and click on “Add” to start the provisioning wizard.

Click "Add" to start provisioning wizard.

Give your storage account a name, location, and other performance characteristics based on your needs. For this article, we are going to use all defaults, except the name and location, and once all options are configured click on “Review + Create.”

Once all performance options are configured, click on "Review + Create."

Navigate to your new Storage Account to see the available options for creating Blobs (Containers), File Shares, Tables, and Queues.

Available options for your Storage account.

Creating a Container (Blob) Storage

Click on the “Containers” button located at the bottom of the Overview screen, then click on the “+” plus symbol next to Container. Choose a name for your blob storage and click on “Create.”

Click on "Create" to create container storage.

Once created, you will see some simple options and the ability to Upload objects plus management options.

Simple options and the ability to Upload objects plus management options.

Externally Connect to Container (Blob) Storage

One of the easiest ways to upload files to Container (Blob) Storage is using the azcopy.exe utility. This allows you to use a Shared Access Signature (SAS) URI to upload the files. Following is an example of using PowerShell with azcopy.exe to upload files. First, let’s create the Shared Access Signature.

Example of using PowerShell with azcopy.exe to upload files.

Next, copy the Blob service SAS URL as this will be used in the azcopy command.

Copy the Blob service SAS URL.

Finally, using the azcopy utility, copy the files or folders (using the -recursive parameter) using the SAS URL that you previously created.

azcopy copy 'C:\Files' {Container SAS URL} –recursive

File Shares

Anyone working in Windows often deals with mounted file shares. Usually, these are located within on-premise file servers. Azure File Shares offers the ability to create a traditional SMB file share that can be connected to via a client supporting the SMB 3.0 protocol.

SMB 3.0 was originally introduced in Windows 8 and Windows Server 2012. Therefore, in using the recommended recent versions of Windows, you should have no problem connecting.

Similar to how we created a blob share, navigate to the “File Shares” section under the Overview section and click on the “+” plus sign next to the File Share button.

Create a file share.

Give the file share a name and choose the appropriate tier. This will give the necessary performance characteristics that you might need depending on your specific application.

Give the file share a name and choose the appropriate tier.

Once again, simple file upload and management abilities exist in the file share management section.

Simple file upload and management abilities in the file share management section.

Externally Connect to a File Share

Because this is a Windows file share, one of the easiest methods for connecting to this share is to use the provided PowerShell script to create the mounted drive in your local desktop or server environment. This does require port 445 to be open and accessible.

Use the provided PowerShell script to create the mounted drive in your local desktop or server environment.

Tables

Azure Storage Tables provide a high-performance key-value store. As prior examples have shown, click on the “Tables” button under the Overview page and click on the “+” plus sign next to the Table button.

Click on the "Tables" button and "+" to add them.

Provide a name for the Table and click on “OK” to quickly provision the table for use.

Name the table and click on "OK."

Externally Connect to a Table

The easiest way to connect to a Table externally, if not via the applications internal coding, is to use PowerShell. This requires the Az module and the AzTable module, and there are native cmdlets available for connecting to a Table.

# Install Az Module
Install-Module -Name 'Az'
# Install Az Table Module
Install-Module -Name 'AzTable'
# Import Module Az and Az Table
Import-Module -Name 'Az'
Import-Module -Name 'AzTable'
# Connect to Azure AD
Connect-AzAccount
# Connect to a specific Storage Account
$storageAccount = Get-AzStorageAccount -Name 'myStorageaccount' -ResourceGroupName 'myRG'
# Connect to a specific Table
$table = Get-AzStorageTable –Name 'myTestTable' –Context $storageAccount.Context
# Add a row to the specified Table
$Params = @{
  "Table"        = $Table.CloudTable
  "PartitionKey" = 'Partition1'
  "RowKey"       = 'Key1'
  "Property"     = @{
    "FirstProperty"  = 'Test Value 1'
    "SecondProperty" = 'Test Value 2'
  }
}

Add-AzTableRow @Params

Queues

Finally, Queues provide asynchronous message queues for easy buffered communications between applications. Just like the other services, navigate to the “Queues” button under the Overview section and click on the “+”  plus sign next to the Queue button.

Navigate to the Queues button and click on the "+" plus sign to add a queue.

Provide a name for the Queue and click on “OK” to quickly provision the queue for use.

Provide a name for the Queue and click on "OK."

Externally Connect to a Queue

The easiest way to connect to a Queue externally, if not via the applications internal coding, is to use PowerShell. This requires the Az module, and because there are no specific cmdlets for interacting with a Queue, the code depends on .NET classes.

# Install the Az Module
Install-Module -Name 'Az'
# Import the Az Module
Import-Module -Name 'Az'
# Connect to Azure AD
Connect-AzAccount
# Connect to a specific Storage Account
$storageAccount = Get-AzStorageAccount -Name 'myStorageAccount' -ResourceGroupName 'myRG'
# Connect to a specific Queue
$queue = Get-AzStorageQueue –Name 'myQueue' –Context $storageAccount.Context
# Create a new message using a constructor of the CloudQueueMessage class
$queueMessage = [Microsoft.Azure.Storage.Queue.CloudQueueMessage]::New("Test Message")
# Add a new message to the queue
$queue.CloudQueue.AddMessageAsync($QueueMessage)

Managing Content via Storage Explorer (preview)

Although certain operations can be done in each individual section, by far the easiest and quickest method to manage each of the four options is via the Storage Explorer (preview). As shown below, each of the available options is available, along with the ability to manage data.

  • Blobs: Upload, Download, Create Folders, Folder Statistics
  • File Shares: Upload, Download, Create Folders, Directory Statistics, Connect VM
  • Queues: View Message, Add Message, Dequeue Message, Clear Queue
  • Tables: Query, Add, Edit, Table Statistics

Available options to manage storage content.

Conclusion

As you can see there are a number of options for managing Storage Account data storage options for Blobs, File Shares, Queues, and Tables. The ease of management is expanded by the use of the Storage Explorer and easy external share and management options.