TableServiceClient class
TableServiceClient 表示 Azure 表服务的客户端,允许对表和实体执行作。
构造函数
Table |
创建 TableServiceClient 类的新实例。 |
Table |
创建 TableServiceClient 类的新实例。 |
Table |
创建 TableServiceClient 类的新实例。 |
Table |
创建 TableServiceClient 类的新实例。 |
方法
create |
在给定帐户下创建新表。 |
delete |
作永久删除指定的表。 |
from |
从连接字符串创建 TableServiceClient 的实例。 |
get |
获取帐户的表服务的属性,包括分析和 CORS(跨域资源共享)规则的属性。 |
get |
检索与表服务的复制相关的统计信息。 仅当为帐户启用读取访问异地冗余复制时,它才可用于辅助位置终结点。 |
list |
查询给定帐户下的表。 |
set |
设置帐户的表服务终结点的属性,包括分析和 CORS(跨域资源共享)规则的属性。 |
构造函数详细信息
TableServiceClient(string, NamedKeyCredential, TableServiceClientOptions)
创建 TableServiceClient 类的新实例。
new TableServiceClient(url: string, credential: NamedKeyCredential, options?: TableServiceClientOptions)
参数
- url
-
string
作为所需作目标的服务帐户的 URL,例如“https://myaccount.table.core.windows.net"。
- credential
- NamedKeyCredential
NamedKeyCredential |用于对请求进行身份验证的 SASCredential。 仅支持 Node
- options
- TableServiceClientOptions
用于配置 HTTP 管道的选项。
使用帐户名称/密钥的示例:
import { AzureNamedKeyCredential, TableServiceClient } from "@azure/data-tables";
const account = "<account>";
const accountKey = "<accountkey>";
const credential = new AzureNamedKeyCredential(account, accountKey);
const serviceClient = new TableServiceClient(
`https://${account}.table.core.windows.net`,
credential,
);
TableServiceClient(string, SASCredential, TableServiceClientOptions)
创建 TableServiceClient 类的新实例。
new TableServiceClient(url: string, credential: SASCredential, options?: TableServiceClientOptions)
参数
- url
-
string
作为所需作目标的服务帐户的 URL,例如“https://myaccount.table.core.windows.net"。
- credential
- SASCredential
用于对请求进行身份验证的 SASCredential
- options
- TableServiceClientOptions
用于配置 HTTP 管道的选项。
使用 SAS 令牌的示例。
import { TableServiceClient, AzureSASCredential } from "@azure/data-tables";
const account = "<account name>";
const sas = "<service Shared Access Signature Token>";
const serviceClientWithSAS = new TableServiceClient(
`https://${account}.table.core.windows.net`,
new AzureSASCredential(sas),
);
TableServiceClient(string, TableServiceClientOptions)
创建 TableServiceClient 类的新实例。
new TableServiceClient(url: string, options?: TableServiceClientOptions)
参数
- url
-
string
作为所需作目标的服务帐户的 URL,例如“https://myaccount.table.core.windows.net"。 可以追加 SAS,例如“https://myaccount.table.core.windows.net?sasString"。
- options
- TableServiceClientOptions
用于配置 HTTP 管道的选项。 追加 SAS 令牌的示例:
import { TableServiceClient } from "@azure/data-tables";
const account = "<account name>";
const sasToken = "<SAS token>";
const tableName = "<tableName>";
const serviceClientWithSASURL = new TableServiceClient(
`https://${account}.table.core.windows.net?${sasToken}`,
);
TableServiceClient(string, TokenCredential, TableServiceClientOptions)
创建 TableServiceClient 类的新实例。
new TableServiceClient(url: string, credential: TokenCredential, options?: TableServiceClientOptions)
参数
- url
-
string
作为所需作目标的服务帐户的 URL,例如“https://myaccount.table.core.windows.net"。
- credential
- TokenCredential
用于对请求进行身份验证的 Azure Active Directory 凭据
- options
- TableServiceClientOptions
用于配置 HTTP 管道的选项。
使用 Azure Active Directory 凭据的示例:
import { DefaultAzureCredential } from "@azure/identity";
import { TableServiceClient } from "@azure/data-tables";
const credential = new DefaultAzureCredential();
const account = "<account name>";
const clientWithAAD = new TableServiceClient(
`https://${account}.table.core.windows.net`,
credential,
);
属性详细信息
pipeline
url
表帐户 URL
url: string
属性值
string
方法详细信息
createTable(string, OperationOptions)
在给定帐户下创建新表。
function createTable(name: string, options?: OperationOptions): Promise<void>
参数
- name
-
string
表的名称。
- options
- OperationOptions
选项参数。
返回
Promise<void>
deleteTable(string, OperationOptions)
作永久删除指定的表。
function deleteTable(name: string, options?: OperationOptions): Promise<void>
参数
- name
-
string
表的名称。
- options
- OperationOptions
选项参数。
返回
Promise<void>
fromConnectionString(string, TableServiceClientOptions)
从连接字符串创建 TableServiceClient 的实例。
static function fromConnectionString(connectionString: string, options?: TableServiceClientOptions): TableServiceClient
参数
- connectionString
-
string
帐户连接字符串或 Azure 存储帐户的 SAS 连接字符串。
[ 注意 - 帐户连接字符串只能在NODE.JS运行时使用。 ] 帐户连接字符串示例 -
DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=accountKey;EndpointSuffix=core.windows.net
SAS 连接字符串示例 - 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
用于配置 HTTP 管道的选项。
返回
给定连接字符串中的新 TableServiceClient。
getProperties(OperationOptions)
获取帐户的表服务的属性,包括分析和 CORS(跨域资源共享)规则的属性。
function getProperties(options?: OperationOptions): Promise<ServiceGetPropertiesResponse>
参数
- options
- OperationOptions
选项参数。
返回
Promise<GetPropertiesResponse>
getStatistics(OperationOptions)
检索与表服务的复制相关的统计信息。 仅当为帐户启用读取访问异地冗余复制时,它才可用于辅助位置终结点。
function getStatistics(options?: OperationOptions): Promise<ServiceGetStatisticsResponse>
参数
- options
- OperationOptions
选项参数。
返回
Promise<GetStatisticsResponse>
listTables(ListTableItemsOptions)
查询给定帐户下的表。
function listTables(options?: ListTableItemsOptions): PagedAsyncIterableIterator<TableItem, TableItemResultPage, PageSettings>
参数
- options
- ListTableItemsOptions
选项参数。
返回
setProperties(TableServiceProperties, ServiceSetPropertiesOptionalParams)
设置帐户的表服务终结点的属性,包括分析和 CORS(跨域资源共享)规则的属性。
function setProperties(properties: TableServiceProperties, options?: ServiceSetPropertiesOptionalParams): Promise<ServiceSetPropertiesHeaders>
参数
- properties
- ServiceProperties
表服务属性。
- options
- SetPropertiesOptions
选项参数。
返回
Promise<ServiceSetPropertiesHeaders>