An isomorphic client library for the Azure Tables service.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
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.
npm install @azure/data-tablesimport {
TableServiceClient,
TableClient,
TableTransaction,
AzureNamedKeyCredential,
AzureSASCredential,
odata
} from "@azure/data-tables";For CommonJS:
const {
TableServiceClient,
TableClient,
TableTransaction,
AzureNamedKeyCredential,
AzureSASCredential,
odata
} = require("@azure/data-tables");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);
}Azure Data Tables is built around several key components:
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>;
}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>[]>;
}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>;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;
}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;
}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;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;