Name of the table to perform operations on.
Table Account URL
Insert entity in the table.
The properties for the table entity.
Creates a table with the tableName passed to the client constructor
Deletes the specified entity in the table.
The partition key of the entity.
The row key of the entity.
Permanently deletes the current table with all of its entities.
Retrieves details about any stored access policies specified on the table that may be used with Shared Access Signatures.
Returns a single entity in the table.
The partition key of the entity.
The row key of the entity.
Queries entities in a table.
Optionaloptions: ListTableEntitiesOptions
The options parameters.
Example listing entities
import { DefaultAzureCredential } from "@azure/identity";
import { TableClient } from "@azure/data-tables";
const account = "<account>";
const accountKey = "<accountkey>";
const tableName = "<tableName>";
const credential = new DefaultAzureCredential();
const client = new TableClient(`https://${account}.table.core.windows.net`, tableName, credential);
let i = 0;
const entities = client.listEntities();
for await (const entity of entities) {
console.log(`Entity${++i}: PartitionKey: ${entity.partitionKey} RowKey: ${entity.rowKey}`);
}
Sets stored access policies for the table that may be used with Shared Access Signatures.
Submits a Transaction which is composed of a set of actions. You can provide the actions as a list or you can use TableTransaction to help building the transaction.
Example usage:
import { DefaultAzureCredential } from "@azure/identity";
import { TableClient, TransactionAction } from "@azure/data-tables";
const account = "<account>";
const accountKey = "<accountkey>";
const tableName = "<tableName>";
const credential = new DefaultAzureCredential();
const client = new TableClient(`https://${account}.table.core.windows.net`, tableName, credential);
const actions: TransactionAction[] = [
["create", { partitionKey: "p1", rowKey: "1", data: "test1" }],
["delete", { partitionKey: "p1", rowKey: "2" }],
["update", { partitionKey: "p1", rowKey: "3", data: "newTest" }, "Merge"],
];
const result = await client.submitTransaction(actions);
Example usage with TableTransaction:
import { DefaultAzureCredential } from "@azure/identity";
import { TableClient, TableTransaction } from "@azure/data-tables";
const account = "<account>";
const accountKey = "<accountkey>";
const tableName = "<tableName>";
const credential = new DefaultAzureCredential();
const client = new TableClient(`https://${account}.table.core.windows.net`, tableName, credential);
const transaction = new TableTransaction();
// Call the available action in the TableTransaction object
transaction.createEntity({ partitionKey: "p1", rowKey: "1", data: "test1" });
transaction.deleteEntity("p1", "2");
transaction.updateEntity({ partitionKey: "p1", rowKey: "3", data: "newTest" }, "Merge");
// submitTransaction with the actions list on the transaction.
const result = await client.submitTransaction(transaction.actions);
tuple that contains the action to perform, and the entity to perform the action with
Update an entity in the table.
The properties of the entity to be updated.
The different modes for updating the entity: - Merge: Updates an entity by updating the entity's properties without replacing the existing entity. - Replace: Updates an existing entity by replacing the entire entity.
Optionaloptions: { etag?: string }
The options parameters.
import { DefaultAzureCredential } from "@azure/identity";
import { TableClient } from "@azure/data-tables";
const account = "<account>";
const accountKey = "<accountkey>";
const tableName = "<tableName>";
const credential = new DefaultAzureCredential();
const client = new TableClient(`https://${account}.table.core.windows.net`, tableName, credential);
const entity = { partitionKey: "p1", rowKey: "r1", bar: "updatedBar" };
// Update uses update mode "Merge" as default
// merge means that update will match a stored entity
// that has the same partitionKey and rowKey as the entity
// passed to the method and then will only update the properties present in it.
// Any other properties that are not defined in the entity passed to updateEntity
// will remain as they are in the service
await client.updateEntity(entity);
// We can also set the update mode to Replace, which will match the entity passed
// to updateEntity with one stored in the service and replace with the new one.
// If there are any missing properties in the entity passed to updateEntity, they
// will be removed from the entity stored in the service
await client.updateEntity(entity, "Replace");
Upsert an entity in the table.
The properties for the table entity.
The different modes for updating the entity: - Merge: Updates an entity by updating the entity's properties without replacing the existing entity. - Replace: Updates an existing entity by replacing the entire entity.
An in-memory mock of the Azure TableClient. It uses a Map to simulate table storage and correctly implements the TableClient interface.
Example