Skip to content

Commit 34ef78d

Browse files
add Azure Table Storage (legacy api) service doc
Co-authored-by: Paolo Salvatori <leprino@hotmail.com> Made-with: Cursor
1 parent b97ae30 commit 34ef78d

File tree

1 file changed

+311
-1
lines changed

1 file changed

+311
-1
lines changed
Lines changed: 311 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,321 @@
11
---
22
title: "Table Storage"
3-
description: API coverage for Microsoft.TableStorage in LocalStack for Azure.
3+
description: Get started with Azure Table Storage in LocalStack
44
template: doc
55
---
66

77
import AzureFeatureCoverage from "../../../../components/feature-coverage/AzureFeatureCoverage";
88

9+
## Introduction
10+
11+
Azure Table Storage is a NoSQL key-value store designed for large volumes of semi-structured data, useful for lightweight metadata, lookup records, and simple operational datasets.
12+
Data is organized into tables, partitions, and entities addressed by PartitionKey and RowKey.
13+
It offers schemaless flexibility at a fraction of the cost of traditional SQL, making it easy to adapt as your application evolves. For more information, see [What is Azure Table storage?](https://learn.microsoft.com/en-us/azure/storage/tables/table-storage-overview)
14+
15+
LocalStack for Azure provides a local environment for building and testing applications that make use of Azure Table Storage.
16+
The supported APIs are available on our [API Coverage section](#api-coverage), which provides information on the extent of Table Storage's integration with LocalStack.
17+
18+
## Getting started
19+
20+
This guide is designed for users new to Table Storage and assumes basic knowledge of the Azure CLI and our `azlocal` wrapper script.
21+
22+
Launch LocalStack using your preferred method. For more information, see [Introduction to LocalStack for Azure](/azure/getting-started/). Once the container is running, enable Azure CLI interception by running:
23+
24+
25+
:::note
26+
As an alternative to using the `azlocal` CLI, users can run:
27+
28+
`azlocal start-interception`
29+
30+
This command points the `az` CLI away from the public Azure management REST API and toward the LocalStack for Azure emulator REST API.
31+
To revert this configuration, run:
32+
33+
`azlocal stop-interception`
34+
35+
This reconfigures the `az` CLI to send commands to the official Azure management REST API.
36+
:::
37+
38+
### Create a resource group
39+
40+
Create a resource group to contain your storage resources:
41+
42+
```bash
43+
az group create \
44+
--name rg-table-demo \
45+
--location westeurope
46+
```
47+
48+
```bash title="Output"
49+
{
50+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-table-demo",
51+
"location": "westeurope",
52+
"managedBy": null,
53+
"name": "rg-table-demo",
54+
"properties": {
55+
"provisioningState": "Succeeded"
56+
},
57+
"tags": null,
58+
"type": "Microsoft.Resources/resourceGroups"
59+
}
60+
```
61+
62+
### Create a storage account
63+
64+
Create a storage account in the resource group:
65+
66+
```bash
67+
az storage account create \
68+
--name sttabledemols \
69+
--resource-group rg-table-demo \
70+
--location westeurope \
71+
--sku Standard_LRS
72+
```
73+
74+
```bash title="Output"
75+
{
76+
...
77+
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-table-demo/providers/Microsoft.Storage/storageAccounts/sttabledemols",
78+
...
79+
"name": "sttabledemols",
80+
...
81+
"placement": null,
82+
"primaryEndpoints": {
83+
"blob": "https://sttabledemols.blob.core.azure.localhost.localstack.cloud:4566",
84+
...
85+
"table": "https://sttabledemols.table.core.azure.localhost.localstack.cloud:4566",
86+
...
87+
},
88+
....
89+
}
90+
```
91+
92+
### Authentication
93+
94+
There are three ways to authenticate storage table commands against the emulator:
95+
96+
#### Storage account key
97+
98+
Retrieve the account key and pass it with `--account-name` and `--account-key`:
99+
100+
```bash
101+
ACCOUNT_KEY=$(az storage account keys list \
102+
--account-name sttabledemols \
103+
--resource-group rg-table-demo \
104+
--query "[0].value" \
105+
--output tsv)
106+
107+
az storage table list \
108+
--account-name sttabledemols \
109+
--account-key "$ACCOUNT_KEY"
110+
```
111+
112+
#### Login credentials
113+
114+
Use `--auth-mode login` to authenticate with the current session credentials:
115+
116+
```bash
117+
az storage table list \
118+
--account-name sttabledemols \
119+
--auth-mode login
120+
```
121+
122+
#### Connection string
123+
124+
Bundle the account name and key into a single value:
125+
126+
```bash
127+
CONNECTION_STRING=$(az storage account show-connection-string \
128+
--name sttabledemols \
129+
--resource-group rg-table-demo \
130+
--query connectionString -o tsv)
131+
132+
az storage table list \
133+
--connection-string "$CONNECTION_STRING"
134+
```
135+
136+
The remaining examples in this guide use connection strings for brevity.
137+
138+
### Create and inspect a table
139+
140+
Create a table:
141+
142+
```bash
143+
az storage table create \
144+
--name apptable \
145+
--connection-string "$CONNECTION_STRING"
146+
```
147+
148+
```bash title="Output"
149+
{
150+
"created": true
151+
}
152+
```
153+
154+
Verify the table exists:
155+
156+
```bash
157+
az storage table exists \
158+
--name apptable \
159+
--connection-string "$CONNECTION_STRING"
160+
```
161+
162+
```bash title="Output"
163+
{
164+
"exists": true
165+
}
166+
```
167+
168+
List tables in the storage account:
169+
170+
```bash
171+
az storage table list \
172+
--connection-string "$CONNECTION_STRING"
173+
```
174+
175+
```bash title="Output"
176+
[
177+
{
178+
"name": "apptable"
179+
}
180+
]
181+
```
182+
183+
### Insert and query entities
184+
185+
Insert an entity into the table:
186+
187+
```bash
188+
az storage entity insert \
189+
--table-name apptable \
190+
--entity PartitionKey=demo RowKey=1 name=Alice score=100 \
191+
--connection-string "$CONNECTION_STRING"
192+
```
193+
194+
```bash title="Output"
195+
{
196+
"content": {
197+
"PartitionKey": "demo",
198+
"RowKey": "1",
199+
"name": "Alice",
200+
"score": 100,
201+
...
202+
},
203+
"etag": "W/\"datetime'...'\"",
204+
...
205+
}
206+
```
207+
208+
Retrieve the entity by its partition key and row key:
209+
210+
```bash
211+
az storage entity show \
212+
--table-name apptable \
213+
--partition-key demo \
214+
--row-key 1 \
215+
--connection-string "$CONNECTION_STRING"
216+
```
217+
218+
```bash title="Output"
219+
{
220+
"PartitionKey": "demo",
221+
"RowKey": "1",
222+
"name": "Alice",
223+
"score": 100,
224+
...
225+
}
226+
```
227+
228+
Query entities by partition key:
229+
230+
```bash
231+
az storage entity query \
232+
--table-name apptable \
233+
--filter "PartitionKey eq 'demo'" \
234+
--connection-string "$CONNECTION_STRING"
235+
```
236+
237+
```bash title="Output"
238+
{
239+
"items": [
240+
{
241+
"PartitionKey": "demo",
242+
"RowKey": "1",
243+
"name": "Alice",
244+
"score": 100,
245+
...
246+
}
247+
],
248+
"nextMarker": {}
249+
}
250+
```
251+
252+
### Update, merge, and delete entities
253+
254+
Update the entity with a merge operation:
255+
256+
```bash
257+
az storage entity merge \
258+
--table-name apptable \
259+
--entity PartitionKey=demo RowKey=1 score=101 \
260+
--connection-string "$CONNECTION_STRING"
261+
```
262+
263+
```bash title="Output"
264+
{
265+
"etag": "W/\"datetime'...'\"",
266+
...
267+
}
268+
```
269+
270+
Delete the entity and verify the table is empty:
271+
272+
```bash
273+
az storage entity delete \
274+
--table-name apptable \
275+
--partition-key demo \
276+
--row-key 1 \
277+
--connection-string "$CONNECTION_STRING"
278+
279+
az storage entity query \
280+
--table-name apptable \
281+
--connection-string "$CONNECTION_STRING"
282+
```
283+
284+
```bash title="Output"
285+
{
286+
"deleted": null
287+
}
288+
{
289+
"items": [],
290+
"nextMarker": {}
291+
}
292+
```
293+
294+
## Features
295+
296+
The Table Storage emulator supports the following features:
297+
298+
- **Data plane REST API**: Table CRUD, entity operations (insert, query, merge, replace, delete), OData query filters, and batch/transaction requests.
299+
- **Control plane REST API**: Create and get tables, get and set table service properties via Azure Resource Manager.
300+
- **Multiple authentication modes**: Storage account key, login credentials, and connection strings.
301+
- **Entity operations**: Insert, query, show, merge, replace, and delete entities with schemaless, key-value data addressed by `PartitionKey` and `RowKey`.
302+
- **OData query support**: Filter and project entities using OData expressions (e.g., `PartitionKey eq 'demo'`).
303+
- **Batch operations**: Entity batch (transaction) requests are proxied with correct URL and authorization rewriting.
304+
305+
## Limitations
306+
307+
- **No data persistence across restarts**: Table data is not persisted and is lost when the LocalStack emulator is stopped or restarted.
308+
- **Table service properties**: `set_service_properties` is a no-op and `get_service_properties` returns empty defaults, unlike Azure where CORS, logging, and metrics settings are persisted and applied.
309+
- **Storage account keys**: Keys are emulator-generated rather than managed by Azure.
310+
- **Header validation**: Unsupported request headers or parameters are silently accepted (Azurite runs in loose mode) instead of being rejected.
311+
- **API version enforcement**: The emulator does not validate the `x-ms-version` header; all API versions are accepted.
312+
313+
## Samples
314+
315+
The following sample demonstrates how to use Table Storage with LocalStack for Azure:
316+
317+
- [Azure Functions Sample with LocalStack for Azure](https://github.com/localstack/localstack-azure-samples/tree/main/samples/function-app-storage-http/dotnet)
318+
9319
## API Coverage
10320

11321
<AzureFeatureCoverage service="Microsoft.TableStorage" client:load />

0 commit comments

Comments
 (0)