diff --git a/src/content/docs/azure/services/table-storage.mdx b/src/content/docs/azure/services/table-storage.mdx index fe8c3616..3912d070 100644 --- a/src/content/docs/azure/services/table-storage.mdx +++ b/src/content/docs/azure/services/table-storage.mdx @@ -1,11 +1,226 @@ --- title: "Table Storage" -description: API coverage for Microsoft.TableStorage in LocalStack for Azure. +description: Get started with Azure Table Storage in LocalStack template: doc --- import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage"; +## Introduction + +Azure Table Storage is a NoSQL key-value store for large volumes of semi-structured data. +With the legacy Table API, data is organized into tables, partitions, and entities addressed by `PartitionKey` and `RowKey`. +It is useful for lightweight metadata, lookup records, and simple operational datasets. + +LocalStack for Azure lets you build and test Table Storage workflows locally using the same CLI flow as cloud environments. +The supported APIs are listed in the [API Coverage](#api-coverage) section. + +## Getting started + +This guide is designed for users new to Azure Table Storage and assumes basic knowledge of the Azure CLI and `azlocal`. + +Start by enabling interception so your `az` commands are routed to LocalStack: + +```bash +azlocal start_interception +``` + +The following example creates a storage account, creates a table, and performs basic entity operations. + +### Create a resource group + +Create a resource group for the storage resources: + +```bash +az group create --name rg-table-legacy-demo --location westeurope +``` + +```bash title="Output" +{ + "name": "rg-table-legacy-demo", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-table-legacy-demo", + "location": "westeurope", + "properties": { + "provisioningState": "Succeeded" + }, + ... +} +``` + +### Create a storage account + +Create a storage account that will host the table service: + +```bash +az storage account create \ + --name stordoc88acct \ + --resource-group rg-table-legacy-demo \ + --location westeurope \ + --sku Standard_LRS \ + --kind StorageV2 +``` + +```bash title="Output" +{ + "name": "stordoc88acct", + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-table-legacy-demo/providers/Microsoft.Storage/storageAccounts/stordoc88acct", + "location": "westeurope", + "kind": "StorageV2", + "provisioningState": "Succeeded", + "primaryEndpoints": { + "table": "https://stordoc88accttable.localhost.localstack.cloud:4566", + ... + }, + ... +} +``` + +### Create and inspect a table + +Get the storage account connection string used for data-plane operations: + +```bash +CONNECTION_STRING=$(az storage account show-connection-string \ + --name stordoc88acct \ + --resource-group rg-table-legacy-demo \ + --query connectionString -o tsv) +``` + +Create a table: + +```bash +az storage table create --name legacytable --connection-string "$CONNECTION_STRING" +``` + +```bash title="Output" +{ + "created": true +} +``` + +Check whether the table exists: + +```bash +az storage table exists --name legacytable --connection-string "$CONNECTION_STRING" +``` + +```bash title="Output" +{ + "exists": true +} +``` + +### Insert and query entities + +Insert an entity into the table: + +```bash +az storage entity insert \ + --connection-string "$CONNECTION_STRING" \ + --table-name legacytable \ + --entity PartitionKey=demo RowKey=1 name=Alice score=100 +``` + +```bash title="Output" +{ + "content": { + "PartitionKey": "demo", + "RowKey": "1", + "name": "Alice", + "score": 100, + ... + }, + "etag": "W/\"datetime'2026-02-27T11%3A37%3A25.7298901Z'\"", + ... +} +``` + +Get the inserted entity: + +```bash +az storage entity show \ + --connection-string "$CONNECTION_STRING" \ + --table-name legacytable \ + --partition-key demo \ + --row-key 1 +``` + +```bash title="Output" +{ + "PartitionKey": "demo", + "RowKey": "1", + "name": "Alice", + "score": 100, + ... +} +``` + +Query entities by partition key: + +```bash +az storage entity query \ + --connection-string "$CONNECTION_STRING" \ + --table-name legacytable \ + --filter "PartitionKey eq 'demo'" +``` + +```bash title="Output" +{ + "items": [ + { + "PartitionKey": "demo", + "RowKey": "1", + "name": "Alice", + "score": 100, + ... + } + ], + "nextMarker": {} +} +``` + +### Update, delete, and verify + +Update the entity with a merge operation: + +```bash +az storage entity merge \ + --connection-string "$CONNECTION_STRING" \ + --table-name legacytable \ + --entity PartitionKey=demo RowKey=1 score=101 +``` + +```bash title="Output" +{ + "etag": "W/\"datetime'2026-02-27T11%3A37%3A27.3795415Z'\"", + ... +} +``` + +Delete the entity and verify the table is empty: + +```bash +az storage entity delete \ + --connection-string "$CONNECTION_STRING" \ + --table-name legacytable \ + --partition-key demo \ + --row-key 1 + +az storage entity query \ + --connection-string "$CONNECTION_STRING" \ + --table-name legacytable +``` + +```bash title="Output" +{ + "deleted": null +} +{ + "items": [], + "nextMarker": {} +} +``` + ## API Coverage