@azure/data-tables 13.3.1-alpha.20250221.1 → 13.3.1-alpha.20250225.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +58 -125
  2. package/dist/browser/TableClient.d.ts +161 -179
  3. package/dist/browser/TableClient.d.ts.map +1 -1
  4. package/dist/browser/TableClient.js +125 -148
  5. package/dist/browser/TableClient.js.map +1 -1
  6. package/dist/browser/TableServiceClient.d.ts +32 -21
  7. package/dist/browser/TableServiceClient.d.ts.map +1 -1
  8. package/dist/browser/TableServiceClient.js.map +1 -1
  9. package/dist/commonjs/TableClient.d.ts +161 -179
  10. package/dist/commonjs/TableClient.d.ts.map +1 -1
  11. package/dist/commonjs/TableClient.js +125 -148
  12. package/dist/commonjs/TableClient.js.map +1 -1
  13. package/dist/commonjs/TableServiceClient.d.ts +32 -21
  14. package/dist/commonjs/TableServiceClient.d.ts.map +1 -1
  15. package/dist/commonjs/TableServiceClient.js.map +1 -1
  16. package/dist/commonjs/tsdoc-metadata.json +1 -1
  17. package/dist/esm/TableClient.d.ts +161 -179
  18. package/dist/esm/TableClient.d.ts.map +1 -1
  19. package/dist/esm/TableClient.js +125 -148
  20. package/dist/esm/TableClient.js.map +1 -1
  21. package/dist/esm/TableServiceClient.d.ts +32 -21
  22. package/dist/esm/TableServiceClient.d.ts.map +1 -1
  23. package/dist/esm/TableServiceClient.js.map +1 -1
  24. package/dist/react-native/TableClient.d.ts +161 -179
  25. package/dist/react-native/TableClient.d.ts.map +1 -1
  26. package/dist/react-native/TableClient.js +125 -148
  27. package/dist/react-native/TableClient.js.map +1 -1
  28. package/dist/react-native/TableServiceClient.d.ts +32 -21
  29. package/dist/react-native/TableServiceClient.d.ts.map +1 -1
  30. package/dist/react-native/TableServiceClient.js.map +1 -1
  31. package/package.json +12 -11
package/README.md CHANGED
@@ -109,14 +109,14 @@ Common uses of the Table service include:
109
109
 
110
110
  To use the clients, import the package in your file:
111
111
 
112
- ```javascript
113
- const AzureTables = require("@azure/data-tables");
112
+ ```ts snippet:ignore
113
+ import * as azureTables from "@azure/data-tables";
114
114
  ```
115
115
 
116
116
  Alternatively, selectively import only the types you need:
117
117
 
118
- ```javascript
119
- const { TableServiceClient, AzureNamedKeyCredential } = require("@azure/data-tables");
118
+ ```ts snippet:ignore
119
+ import { TableServiceClient, AzureNamedKeyCredential } from "@azure/data-tables";
120
120
  ```
121
121
 
122
122
  ### Create the Table service client
@@ -128,8 +128,8 @@ The `TableServiceClient` requires a URL to the table service and an access crede
128
128
  You can instantiate a `TableServiceClient` with a `AzureNamedKeyCredential` by passing account-name and account-key as arguments. (The account-name and account-key can be obtained from the azure portal.)
129
129
  [ONLY AVAILABLE IN NODE.JS RUNTIME]
130
130
 
131
- ```javascript
132
- const { TableServiceClient, AzureNamedKeyCredential } = require("@azure/data-tables");
131
+ ```ts snippet:ReadmeSampleCreateClient_NamedKeyCredential
132
+ import { AzureNamedKeyCredential, TableServiceClient } from "@azure/data-tables";
133
133
 
134
134
  const account = "<account>";
135
135
  const accountKey = "<accountkey>";
@@ -152,9 +152,9 @@ To access a table resource with a `TokenCredential`, the authenticated identity
152
152
  With the `@azure/identity` package, you can seamlessly authorize requests in both development and production environments.
153
153
  To learn more about Azure AD integration in Azure Storage, see the [Azure.Identity README](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md)
154
154
 
155
- ```javascript
156
- const { TableServiceClient } = require("@azure/data-tables");
157
- const { DefaultAzureCredential } = require("@azure/identity");
155
+ ```ts snippet:ReadmeSampleCreateClient_TokenCredential
156
+ import { DefaultAzureCredential } from "@azure/identity";
157
+ import { TableServiceClient } from "@azure/data-tables";
158
158
 
159
159
  // DefaultAzureCredential expects the following three environment variables:
160
160
  // - AZURE_TENANT_ID: The tenant ID in Azure Active Directory
@@ -173,8 +173,8 @@ const clientWithAAD = new TableServiceClient(
173
173
 
174
174
  Also, You can instantiate a `TableServiceClient` with a shared access signatures (SAS). You can get the SAS token from the Azure Portal.
175
175
 
176
- ```javascript
177
- const { TableServiceClient, AzureSASCredential } = require("@azure/data-tables");
176
+ ```ts snippet:ReadmeSampleCreateClient_SASToken
177
+ import { TableServiceClient, AzureSASCredential } from "@azure/data-tables";
178
178
 
179
179
  const account = "<account name>";
180
180
  const sas = "<service Shared Access Signature Token>";
@@ -189,8 +189,8 @@ const serviceClientWithSAS = new TableServiceClient(
189
189
 
190
190
  You can list tables within an account through a `TableServiceClient` instance calling the `listTables` function. This function returns a `PageableAsyncIterator` that you can consume using `for-await-of`
191
191
 
192
- ```javascript
193
- const { TableServiceClient, AzureNamedKeyCredential } = require("@azure/data-tables");
192
+ ```ts snippet:ReadmeSampleListTables
193
+ import { AzureNamedKeyCredential, TableServiceClient } from "@azure/data-tables";
194
194
 
195
195
  const account = "<account>";
196
196
  const accountKey = "<accountkey>";
@@ -201,22 +201,11 @@ const serviceClient = new TableServiceClient(
201
201
  credential,
202
202
  );
203
203
 
204
- async function main() {
205
- const tablesIter = serviceClient.listTables();
206
- let i = 1;
207
- for await (const table of tablesIter) {
208
- console.log(`Table${i}: ${table.name}`);
209
- i++;
210
- // Output:
211
- // Table1: testTable1
212
- // Table1: testTable2
213
- // Table1: testTable3
214
- // Table1: testTable4
215
- // Table1: testTable5
216
- }
204
+ let i = 0;
205
+ const tables = serviceClient.listTables();
206
+ for await (const table of tables) {
207
+ console.log(`Table${++i}: ${table.name}`);
217
208
  }
218
-
219
- main();
220
209
  ```
221
210
 
222
211
  #### Create a new table
@@ -224,8 +213,8 @@ main();
224
213
  You can create a table through a `TableServiceClient` instance calling the `createTable` function. This function takes the name of the table to create as a parameter.
225
214
  Note that `createTable` won't throw an error when the table already exists.
226
215
 
227
- ```javascript
228
- const { TableServiceClient, AzureNamedKeyCredential } = require("@azure/data-tables");
216
+ ```ts snippet:ReadmeSampleCreateTable
217
+ import { AzureNamedKeyCredential, TableServiceClient } from "@azure/data-tables";
229
218
 
230
219
  const account = "<account>";
231
220
  const accountKey = "<accountkey>";
@@ -236,19 +225,15 @@ const serviceClient = new TableServiceClient(
236
225
  credential,
237
226
  );
238
227
 
239
- async function main() {
240
- const tableName = `newtable`;
241
- // If the table 'newTable' already exists, createTable doesn't throw
242
- await serviceClient.createTable(tableName);
243
- }
244
-
245
- main();
228
+ const tableName = "newtable";
229
+ // If the table 'newTable' already exists, createTable doesn't throw
230
+ await serviceClient.createTable(tableName);
246
231
  ```
247
232
 
248
233
  Here is a sample that demonstrates how to test if the table already exists when attempting to create it:
249
234
 
250
- ```javascript
251
- const { TableServiceClient, AzureNamedKeyCredential } = require("@azure/data-tables");
235
+ ```ts snippet:ReadmeSampleCreateTable_IfExists
236
+ import { AzureNamedKeyCredential, TableServiceClient } from "@azure/data-tables";
252
237
 
253
238
  const account = "<account>";
254
239
  const accountKey = "<accountkey>";
@@ -259,18 +244,14 @@ const serviceClient = new TableServiceClient(
259
244
  credential,
260
245
  );
261
246
 
262
- async function main() {
263
- const tableName = `newtable${new Date().getTime()}`;
264
- await serviceClient.createTable(tableName, {
265
- onResponse: (response) => {
266
- if (response.status === 409) {
267
- console.log(`Table ${tableName} already exists`);
268
- }
269
- },
270
- });
271
- }
272
-
273
- main();
247
+ const tableName = `newtable${+new Date()}`;
248
+ await serviceClient.createTable(tableName, {
249
+ onResponse: (response) => {
250
+ if (response.status === 409) {
251
+ console.log(`Table ${tableName} already exists`);
252
+ }
253
+ },
254
+ });
274
255
  ```
275
256
 
276
257
  ### Create the table client
@@ -282,8 +263,8 @@ The `TableClient` is created in a similar way as the `TableServiceClient` with t
282
263
  You can instantiate a `TableClient` with a `AzureNamedKeyCredential` by passing account-name and account-key as arguments. (The account-name and account-key can be obtained from the azure portal.)
283
264
  [ONLY AVAILABLE IN NODE.JS RUNTIME]
284
265
 
285
- ```javascript
286
- const { TableClient, AzureNamedKeyCredential } = require("@azure/data-tables");
266
+ ```ts snippet:ReadmeSampleCreateTableClient_NamedKeyCredential
267
+ import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables";
287
268
 
288
269
  // Enter your storage account name and shared key
289
270
  const account = "<account>";
@@ -307,9 +288,9 @@ To access a table resource with a `TokenCredential`, the authenticated identity
307
288
  With the `@azure/identity` package, you can seamlessly authorize requests in both development and production environments.
308
289
  To learn more about Azure AD integration in Azure Storage, see the [Azure.Identity README](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md)
309
290
 
310
- ```javascript
311
- const { TableClient } = require("@azure/data-tables");
312
- const { DefaultAzureCredential } = require("@azure/identity");
291
+ ```ts snippet:ReadmeSampleCreateTableClient_TokenCredential
292
+ import { DefaultAzureCredential } from "@azure/identity";
293
+ import { TableClient } from "@azure/data-tables";
313
294
 
314
295
  // DefaultAzureCredential expects the following three environment variables:
315
296
  // - AZURE_TENANT_ID: The tenant ID in Azure Active Directory
@@ -330,8 +311,8 @@ const clientWithAAD = new TableClient(
330
311
 
331
312
  You can instantiate a `TableClient` with a shared access signatures (SAS). You can get the SAS token from the Azure Portal.
332
313
 
333
- ```javascript
334
- const { TableClient, AzureSASCredential } = require("@azure/data-tables");
314
+ ```ts snippet:ReadmeSampleCreateTableClient_SASToken
315
+ import { TableClient, AzureSASCredential } from "@azure/data-tables";
335
316
 
336
317
  const account = "<account name>";
337
318
  const sas = "<service Shared Access Signature Token>";
@@ -344,42 +325,12 @@ const clientWithSAS = new TableClient(
344
325
  );
345
326
  ```
346
327
 
347
- #### `TableClient` with TokenCredential (AAD)
348
-
349
- Azure Tables provides integration with Azure Active Directory (Azure AD) for identity-based authentication of requests
350
- to the Table service when targeting a Storage endpoint. With Azure AD, you can use role-based access control (RBAC) to
351
- grant access to your Azure Table resources to users, groups, or applications.
352
-
353
- To access a table resource with a `TokenCredential`, the authenticated identity should have either the "Storage Table Data Contributor" or "Storage Table Data Reader" role.
354
-
355
- With the `@azure/identity` package, you can seamlessly authorize requests in both development and production environments.
356
- To learn more about Azure AD integration in Azure Storage, see the [Azure.Identity README](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md)
357
-
358
- ```javascript
359
- const { TableClient } = require("@azure/data-tables");
360
- const { DefaultAzureCredential } = require("@azure/identity");
361
-
362
- // DefaultAzureCredential expects the following three environment variables:
363
- // - AZURE_TENANT_ID: The tenant ID in Azure Active Directory
364
- // - AZURE_CLIENT_ID: The application (client) ID registered in the AAD tenant
365
- // - AZURE_CLIENT_SECRET: The client secret for the registered application
366
- const credential = new DefaultAzureCredential();
367
- const account = "<account name>";
368
- const tableName = "<tableName>";
369
-
370
- const clientWithAAD = new TableClient(
371
- `https://${account}.table.core.windows.net`,
372
- tableName,
373
- credential,
374
- );
375
- ```
376
-
377
328
  #### List Entities in a table
378
329
 
379
330
  You can list entities within a table by through a `TableClient` instance calling the `listEntities` function. This function returns a `PageableAsyncIterator` that you can consume using `for-await-of`
380
331
 
381
- ```javascript
382
- const { TableClient, AzureNamedKeyCredential } = require("@azure/data-tables");
332
+ ```ts snippet:ReadmeSampleListEntities
333
+ import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables";
383
334
 
384
335
  const account = "<account>";
385
336
  const accountKey = "<accountkey>";
@@ -388,29 +339,19 @@ const tableName = "<tableName>";
388
339
  const credential = new AzureNamedKeyCredential(account, accountKey);
389
340
  const client = new TableClient(`https://${account}.table.core.windows.net`, tableName, credential);
390
341
 
391
- async function main() {
392
- const entitiesIter = client.listEntities();
393
- let i = 1;
394
- for await (const entity of entitiesIter) {
395
- console.log(`Entity${i}: PartitionKey: ${entity.partitionKey} RowKey: ${entity.rowKey}`);
396
- i++;
397
- // Output:
398
- // Entity1: PartitionKey: P1 RowKey: R1
399
- // Entity2: PartitionKey: P2 RowKey: R2
400
- // Entity3: PartitionKey: P3 RowKey: R3
401
- // Entity4: PartitionKey: P4 RowKey: R4
402
- }
342
+ let i = 0;
343
+ const entities = client.listEntities();
344
+ for await (const entity of entities) {
345
+ console.log(`Entity${++i}: PartitionKey: ${entity.partitionKey} RowKey: ${entity.rowKey}`);
403
346
  }
404
-
405
- main();
406
347
  ```
407
348
 
408
349
  #### Create a new entity and add it to a table
409
350
 
410
351
  You can create a new Entity in a table by through a `TableClient` instance calling the `createEntity` function. This function takes the entity to insert as a parameter. The entity must contain `partitionKey` and `rowKey`.
411
352
 
412
- ```javascript
413
- const { TableClient, AzureNamedKeyCredential } = require("@azure/data-tables");
353
+ ```ts snippet:ReadmeSampleCreateEntity
354
+ import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables";
414
355
 
415
356
  const account = "<account>";
416
357
  const accountKey = "<accountkey>";
@@ -419,17 +360,13 @@ const tableName = "<tableName>";
419
360
  const credential = new AzureNamedKeyCredential(account, accountKey);
420
361
  const client = new TableClient(`https://${account}.table.core.windows.net`, tableName, credential);
421
362
 
422
- async function main() {
423
- const testEntity = {
424
- partitionKey: "P1",
425
- rowKey: "R1",
426
- foo: "foo",
427
- bar: 123,
428
- };
429
- await client.createEntity(testEntity);
430
- }
431
-
432
- main();
363
+ const testEntity = {
364
+ partitionKey: "P1",
365
+ rowKey: "R1",
366
+ foo: "foo",
367
+ bar: 123,
368
+ };
369
+ await client.createEntity(testEntity);
433
370
  ```
434
371
 
435
372
  ## Azurite and Storage Emulator
@@ -440,7 +377,7 @@ The Azure Tables Client SDK also works with Azurite, an Azure Storage and Tables
440
377
 
441
378
  The easiest way to connect to Azurite from your application is to configure a connection string that references the shortcut `UseDevelopmentStorage=true`. The shortcut is equivalent to the full connection string for the emulator, which specifies the account name, the account key, and the emulator endpoints for each of the Azure Storage services: ([see more](https://github.com/Azure/Azurite#http-connection-strings)). Using this shortcut, the Azure Tables Client SDK would setup the default connection string and `allowInsecureConnection` in the client options.
442
379
 
443
- ```typescript
380
+ ```ts snippet:ReadmeSampleCreateTableClient_ConnectionString
444
381
  import { TableClient } from "@azure/data-tables";
445
382
 
446
383
  const connectionString = "UseDevelopmentStorage=true";
@@ -451,7 +388,7 @@ const client = TableClient.fromConnectionString(connectionString, "myTable");
451
388
 
452
389
  You can connect to azurite manually without using the connection string shortcut by specifying the service URL and `AzureNamedKeyCredential` or a custom connection string. However, `allowInsecureConnection` will need to be set manually in case Azurite runs in an `http` endpoint.
453
390
 
454
- ```typescript
391
+ ```ts snippet:ReadmeSampleCreateTableClient_Azurite
455
392
  import { TableClient, AzureNamedKeyCredential } from "@azure/data-tables";
456
393
 
457
394
  const client = new TableClient(
@@ -473,16 +410,12 @@ When you interact with Tables service using the Javascript/Typescript SDK, error
473
410
 
474
411
  Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
475
412
 
476
- ```javascript
477
- const { setLogLevel } = require("@azure/logger");
413
+ ```ts snippet:SetLogLevel
414
+ import { setLogLevel } from "@azure/logger";
478
415
 
479
416
  setLogLevel("info");
480
417
  ```
481
418
 
482
- ## Next steps
483
-
484
- More code samples coming soon Issue#10531
485
-
486
419
  ## Contributing
487
420
 
488
421
  This project welcomes contributions and suggestions. Most contributions require you to agree to a