TableServiceClient class

A TableServiceClient represents a Client to the Azure Tables service allowing you to perform operations on the tables and the entities.

Constructors

TableServiceClient(string, NamedKeyCredential, TableServiceClientOptions)

Creates a new instance of the TableServiceClient class.

TableServiceClient(string, SASCredential, TableServiceClientOptions)

Creates a new instance of the TableServiceClient class.

TableServiceClient(string, TableServiceClientOptions)

Creates a new instance of the TableServiceClient class.

TableServiceClient(string, TokenCredential, TableServiceClientOptions)

Creates a new instance of the TableServiceClient class.

Properties

pipeline

Represents a pipeline for making a HTTP request to a URL. Pipelines can have multiple policies to manage manipulating each request before and after it is made to the server.

url

Table Account URL

Methods

createTable(string, OperationOptions)

Creates a new table under the given account.

deleteTable(string, OperationOptions)

Operation permanently deletes the specified table.

fromConnectionString(string, TableServiceClientOptions)

Creates an instance of TableServiceClient from connection string.

getProperties(OperationOptions)

Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules.

getStatistics(OperationOptions)

Retrieves statistics related to replication for the Table service. It is only available on the secondary location endpoint when read-access geo-redundant replication is enabled for the account.

listTables(ListTableItemsOptions)

Queries tables under the given account.

setProperties(ServiceProperties, SetPropertiesOptions)

Sets properties for an account's Table service endpoint, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules.

Constructor Details

TableServiceClient(string, NamedKeyCredential, TableServiceClientOptions)

Creates a new instance of the TableServiceClient class.

new TableServiceClient(url: string, credential: NamedKeyCredential, options?: TableServiceClientOptions)

Parameters

url

string

The URL of the service account that is the target of the desired operation., such as "https://myaccount.table.core.windows.net".

credential
NamedKeyCredential

NamedKeyCredential | SASCredential used to authenticate requests. Only Supported for Node

options
TableServiceClientOptions

Options to configure the HTTP pipeline.

Example using an account name/key:

const { AzureNamedKeyCredential, TableServiceClient } = require("@azure/data-tables")
const account = "<storage account name>"
const sharedKeyCredential = new AzureNamedKeyCredential(account, "<account key>");

const tableServiceClient = new TableServiceClient(
  `https://${account}.table.core.windows.net`,
  sharedKeyCredential
);

TableServiceClient(string, SASCredential, TableServiceClientOptions)

Creates a new instance of the TableServiceClient class.

new TableServiceClient(url: string, credential: SASCredential, options?: TableServiceClientOptions)

Parameters

url

string

The URL of the service account that is the target of the desired operation., such as "https://myaccount.table.core.windows.net".

credential
SASCredential

SASCredential used to authenticate requests

options
TableServiceClientOptions

Options to configure the HTTP pipeline.

Example using a SAS Token.

const { AzureSASCredential, TableServiceClient } = require("@azure/data-tables")
const account = "<storage account name>"
const sasCredential = new AzureSASCredential(account, "<account key>");

const tableServiceClient = new TableServiceClient(
  `https://${account}.table.core.windows.net`,
  sasCredential
);

TableServiceClient(string, TableServiceClientOptions)

Creates a new instance of the TableServiceClient class.

new TableServiceClient(url: string, options?: TableServiceClientOptions)

Parameters

url

string

The URL of the service account that is the target of the desired operation., such as "https://myaccount.table.core.windows.net". You can append a SAS, such as "https://myaccount.table.core.windows.net?sasString".

options
TableServiceClientOptions

Options to configure the HTTP pipeline. Example appending a SAS token:

const account = "<storage account name>";
const sasToken = "<SAS token>";

const tableServiceClient = new TableServiceClient(
  `https://${account}.table.core.windows.net?${sasToken}`,
);

TableServiceClient(string, TokenCredential, TableServiceClientOptions)

Creates a new instance of the TableServiceClient class.

new TableServiceClient(url: string, credential: TokenCredential, options?: TableServiceClientOptions)

Parameters

url

string

The URL of the service account that is the target of the desired operation., such as "https://myaccount.table.core.windows.net".

credential
TokenCredential

Azure Active Directory credential used to authenticate requests

options
TableServiceClientOptions

Options to configure the HTTP pipeline.

Example using an Azure Active Directory credential:

cons { DefaultAzureCredential } = require("@azure/identity");
const { TableServiceClient } = require("@azure/data-tables")
const account = "<storage account name>"
const credential = new DefaultAzureCredential();

const tableServiceClient = new TableServiceClient(
  `https://${account}.table.core.windows.net`,
  credential
);

Property Details

pipeline

Represents a pipeline for making a HTTP request to a URL. Pipelines can have multiple policies to manage manipulating each request before and after it is made to the server.

pipeline: Pipeline

Property Value

url

Table Account URL

url: string

Property Value

string

Method Details

createTable(string, OperationOptions)

Creates a new table under the given account.

function createTable(name: string, options?: OperationOptions): Promise<void>

Parameters

name

string

The name of the table.

options
OperationOptions

The options parameters.

Returns

Promise<void>

deleteTable(string, OperationOptions)

Operation permanently deletes the specified table.

function deleteTable(name: string, options?: OperationOptions): Promise<void>

Parameters

name

string

The name of the table.

options
OperationOptions

The options parameters.

Returns

Promise<void>

fromConnectionString(string, TableServiceClientOptions)

Creates an instance of TableServiceClient from connection string.

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

Parameters

connectionString

string

Account connection string or a SAS connection string of an Azure storage account. [ Note - Account connection string can only be used in NODE.JS runtime. ] Account connection string example - DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net SAS connection string example - BlobEndpoint=https://myaccount.table.core.windows.net/;QueueEndpoint=https://myaccount.queue.core.windows.net/;FileEndpoint=https://myaccount.file.core.windows.net/;TableEndpoint=https://myaccount.table.core.windows.net/;SharedAccessSignature=sasString

options
TableServiceClientOptions

Options to configure the HTTP pipeline.

Returns

A new TableServiceClient from the given connection string.

getProperties(OperationOptions)

Gets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules.

function getProperties(options?: OperationOptions): Promise<GetPropertiesResponse>

Parameters

options
OperationOptions

The options parameters.

Returns

getStatistics(OperationOptions)

Retrieves statistics related to replication for the Table service. It is only available on the secondary location endpoint when read-access geo-redundant replication is enabled for the account.

function getStatistics(options?: OperationOptions): Promise<GetStatisticsResponse>

Parameters

options
OperationOptions

The options parameters.

Returns

listTables(ListTableItemsOptions)

Queries tables under the given account.

function listTables(options?: ListTableItemsOptions): PagedAsyncIterableIterator<TableItem, TableItemResultPage, PageSettings>

Parameters

options
ListTableItemsOptions

The options parameters.

Returns

setProperties(ServiceProperties, SetPropertiesOptions)

Sets properties for an account's Table service endpoint, including properties for Analytics and CORS (Cross-Origin Resource Sharing) rules.

function setProperties(properties: ServiceProperties, options?: SetPropertiesOptions): Promise<ServiceSetPropertiesHeaders>

Parameters

properties
ServiceProperties

The Table Service properties.

options
SetPropertiesOptions

The options parameters.

Returns