CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-azure--data-tables

An isomorphic client library for the Azure Tables service.

Pending
Overview
Eval results
Files

Azure Data Tables

Azure Data Tables is an isomorphic client library for the Azure Tables service, providing complete management of tables, entities, and transactions. It offers both service-level operations for managing tables and table-level operations for CRUD operations on entities, with full TypeScript support and batch transaction capabilities.

Package Information

  • Package Name: @azure/data-tables
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @azure/data-tables

Core Imports

import { 
  TableServiceClient, 
  TableClient, 
  TableTransaction,
  AzureNamedKeyCredential, 
  AzureSASCredential,
  odata
} from "@azure/data-tables";

For CommonJS:

const { 
  TableServiceClient, 
  TableClient, 
  TableTransaction,
  AzureNamedKeyCredential, 
  AzureSASCredential,
  odata
} = require("@azure/data-tables");

Basic Usage

import { TableServiceClient, TableClient, AzureNamedKeyCredential } from "@azure/data-tables";

// Create credentials
const credential = new AzureNamedKeyCredential("accountName", "accountKey");

// Service-level operations
const serviceClient = new TableServiceClient("https://myaccount.table.core.windows.net", credential);
await serviceClient.createTable("MyTable");

// Table-level operations
const tableClient = new TableClient("https://myaccount.table.core.windows.net", "MyTable", credential);

// Create an entity
await tableClient.createEntity({
  partitionKey: "MyPartition",
  rowKey: "MyRow", 
  name: "John Doe",
  age: 30
});

// Query entities
const entities = tableClient.listEntities();
for await (const entity of entities) {
  console.log(entity);
}

Architecture

Azure Data Tables is built around several key components:

  • TableServiceClient: Service-level operations for managing tables, getting statistics, and configuring properties
  • TableClient: Table-level operations for entity CRUD, transactions, and access policies
  • TableTransaction: Helper class for building batch operations with automatic partitioning
  • Authentication: Support for Named Key, SAS, and Token credentials with connection string convenience methods
  • OData Queries: Template literal function for safe query construction with automatic escaping

Capabilities

Table Service Management

Service-level operations for managing tables, retrieving service statistics, and configuring table service properties.

class TableServiceClient {
  constructor(url: string, credential: NamedKeyCredential, options?: TableServiceClientOptions);
  constructor(url: string, credential: SASCredential, options?: TableServiceClientOptions);
  constructor(url: string, credential: TokenCredential, options?: TableServiceClientOptions);
  constructor(url: string, options?: TableServiceClientOptions);

  static fromConnectionString(connectionString: string, options?: TableServiceClientOptions): TableServiceClient;

  createTable(name: string, options?: OperationOptions): Promise<void>;
  deleteTable(name: string, options?: OperationOptions): Promise<void>;
  listTables(options?: ListTableItemsOptions): PagedAsyncIterableIterator<TableItem, TableItem[]>;
  getStatistics(options?: OperationOptions): Promise<GetStatisticsResponse>;
  getProperties(options?: OperationOptions): Promise<GetPropertiesResponse>;
  setProperties(properties: ServiceProperties, options?: SetPropertiesOptions): Promise<SetPropertiesResponse>;
}

Table Service Client

Entity Operations

Complete CRUD operations for table entities with type safety, OData querying, and pagination support.

class TableClient {
  constructor(url: string, tableName: string, credential: NamedKeyCredential, options?: TableClientOptions);
  constructor(url: string, tableName: string, credential: SASCredential, options?: TableClientOptions);
  constructor(url: string, tableName: string, credential: TokenCredential, options?: TableClientOptions);
  constructor(url: string, tableName: string, options?: TableClientOptions);

  static fromConnectionString(connectionString: string, tableName: string, options?: TableClientOptions): TableClient;

  createEntity<T extends object>(entity: TableEntity<T>, options?: OperationOptions): Promise<CreateTableEntityResponse>;
  getEntity<T extends object>(partitionKey: string, rowKey: string, options?: GetTableEntityOptions): Promise<GetTableEntityResponse<TableEntityResult<T>>>;
  updateEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode, options?: UpdateTableEntityOptions): Promise<UpdateEntityResponse>;
  upsertEntity<T extends object>(entity: TableEntity<T>, mode?: UpdateMode, options?: OperationOptions): Promise<UpsertEntityResponse>;
  deleteEntity(partitionKey: string, rowKey: string, options?: DeleteTableEntityOptions): Promise<DeleteTableEntityResponse>;
  listEntities<T extends object>(options?: ListTableEntitiesOptions): PagedAsyncIterableIterator<TableEntityResult<T>, TableEntityResult<T>[]>;
}

Table Client

Transaction Operations

Batch operations for performing multiple entity operations atomically within the same partition.

class TableTransaction {
  constructor(actions?: TransactionAction[]);
  
  readonly actions: TransactionAction[];
  
  createEntity<T extends object>(entity: TableEntity<T>): void;
  deleteEntity(partitionKey: string, rowKey: string): void;
  updateEntity<T extends object>(entity: TableEntity<T>, updateMode?: UpdateMode): void;
  upsertEntity<T extends object>(entity: TableEntity<T>, updateMode?: UpdateMode): void;
}

// Submit via TableClient
submitTransaction(actions: TransactionAction[]): Promise<TableTransactionResponse>;

Transaction Operations

Core Types and Interfaces

Essential types for entity modeling, query options, and API responses.

type TableEntity<T extends object = Record<string, unknown>> = T & {
  partitionKey: string;
  rowKey: string;
};

type TableEntityResult<T> = T & {
  etag: string;
  partitionKey?: string;
  rowKey?: string;
  timestamp?: string;
};

type UpdateMode = "Merge" | "Replace";

type EdmTypes = "Binary" | "Boolean" | "DateTime" | "Double" | "Guid" | "Int32" | "Int64" | "String";

interface Edm<T extends EdmTypes> {
  value: T extends "Binary"
    ? Uint8Array
    : T extends "Boolean"
    ? boolean
    : T extends "Double"
    ? number
    : T extends "Int32"
    ? number
    : string;
  type: T;
}

Types and Interfaces

SAS (Shared Access Signature)

Complete SAS generation and management for both account-level and table-level access control.

function generateAccountSas(credential: NamedKeyCredential, options?: AccountSasOptions): string;
function generateTableSas(tableName: string, credential: NamedKeyCredential, options?: TableSasSignatureValues): string;

interface AccountSasPermissions {
  query?: boolean;
  write?: boolean;
  delete?: boolean;
  list?: boolean;
  add?: boolean;
  update?: boolean;
}

interface TableSasPermissions {
  query?: boolean;
  add?: boolean;
  update?: boolean;
  delete?: boolean;
}

SAS Generation

Authentication

Multiple authentication methods with convenient connection string parsing.

class AzureNamedKeyCredential {
  constructor(name: string, key: string);
}

class AzureSASCredential {
  constructor(signature: string);
}

// Connection string convenience methods
TableServiceClient.fromConnectionString(connectionString: string, options?: TableServiceClientOptions): TableServiceClient;
TableClient.fromConnectionString(connectionString: string, tableName: string, options?: TableClientOptions): TableClient;

Authentication Methods

OData Query Helper

Template literal function for constructing safe OData filter expressions with automatic value escaping.

/**
 * Template literal function for safe OData query construction
 * Automatically escapes string values and prevents injection attacks
 * @param strings - Template literal strings
 * @param values - Template literal values to escape
 * @returns Escaped OData filter string
 */
function odata(strings: TemplateStringsArray, ...values: unknown[]): string;

Install with Tessl CLI

npx tessl i tessl/npm-azure--data-tables
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@azure/data-tables@12.1.x
Publish Source
CLI
Badge
tessl/npm-azure--data-tables badge