How to use the command `az storage table` (with examples)

How to use the command `az storage table` (with examples)

The az storage table command is part of the Azure CLI and allows you to manage NoSQL key-value storage in Azure. It provides functionalities such as creating new tables, generating shared access signatures, listing tables, and deleting tables in a storage account.

Use case 1: Create a new table in the storage account

Code:

az storage table create --account-name storage_account_name --name table_name --fail-on-exist

Motivation: Creating a new table in the storage account allows you to organize and store data in a NoSQL key-value format. This can be useful when you want to manage large amounts of structured data and perform queries efficiently.

Explanation:

  • storage_account_name: The name of the storage account where the table will be created.
  • table_name: The name of the table to be created.
  • --fail-on-exist: Optional parameter to specify whether to fail if the table already exists. If not specified, the default behavior is to overwrite the existing table.

Example output:

{
  "TableName": "table_name"
}

Use case 2: Generate a shared access signature for the table

Code:

az storage table generate-sas --account-name storage_account_name --name table_name --permissions sas_permissions --expiry expiry_date --https-only

Motivation: Generating a shared access signature (SAS) for the table allows you to provide temporary access to the table without sharing your account key. This is useful when you need to grant access to the table for a specific period or for specific permissions.

Explanation:

  • storage_account_name: The name of the storage account where the table is located.
  • table_name: The name of the table for which the SAS will be generated.
  • sas_permissions: The permissions to grant for the SAS. It can be a combination of the following values: ‘r’ (read), ‘a’ (add), ‘u’ (update), ’d’ (delete).
  • expiry_date: The expiry date and time for the SAS. After this date, the SAS will no longer be valid.
  • --https-only: Optional parameter to specify that the SAS can only be used over HTTPS.

Example output:

{
  "SasToken": "?st=2019-12-01T00%3A00%3A00Z&se=2019-12-31T23%3A59%3A59Z&sp=r&sv=2018-03-28&tn=table_name&sig=XXXXXXXXXXXXXXXXXXXXX"
}

Use case 3: List tables in a storage account

Code:

az storage table list --account-name storage_account_name

Motivation: Listing tables in a storage account allows you to retrieve an overview of all the tables present. This can be useful for monitoring and managing the tables within your storage account.

Explanation:

  • storage_account_name: The name of the storage account for which the tables will be listed.

Example output:

[
  {
    "TableName": "table1"
  },
  {
    "TableName": "table2"
  },
  {
    "TableName": "table3"
  }
]

Use case 4: Delete the specified table and any data it contains

Code:

az storage table delete --account-name storage_account_name --name table_name --fail-not-exist

Motivation: Deleting a table and its data can help you clean up unnecessary tables and free up storage space. It is important to note that this action cannot be undone, so make sure to use it with caution.

Explanation:

  • storage_account_name: The name of the storage account where the table is located.
  • table_name: The name of the table to be deleted.
  • --fail-not-exist: Optional parameter to specify whether to fail if the table does not exist. If not specified, the default behavior is to delete the table if it exists.

Example output:

{
  "StatusCode": 204
}

Conclusion:

The az storage table command provides a set of functionalities to manage NoSQL key-value storage in Azure. By using this command, you can create, access, and delete tables in a storage account, making it easier to organize and store structured data efficiently.

Related Posts

How to use the command 'pathping' (with examples)

How to use the command 'pathping' (with examples)

The ‘pathping’ command is a Windows utility that combines the features of ‘ping’ and ’tracert’ to provide a more detailed analysis of the network path between a source and a destination.

Read More
ceph (with examples)

ceph (with examples)

1: Check cluster health status ceph status Motivation: Checking the cluster health status helps administrators identify any potential issues or problems with the Ceph storage system.

Read More
How to use the command lsscsi (with examples)

How to use the command lsscsi (with examples)

The lsscsi command is used to list SCSI devices (or hosts) and their attributes.

Read More