public final class TableServiceAsyncClient extends Object
The client encapsulates the URL for the Tables service endpoint and the credentials for accessing the storage or CosmosDB table API account. It provides methods to create, delete, and list tables within the account. These methods invoke REST API operations to make the requests and obtain the results that are returned.
Instances of this client are obtained by calling the TableServiceClientBuilder.buildAsyncClient() method
on a TableServiceClientBuilder object.
Samples to construct an async client
TableServiceAsyncClient tableServiceAsyncClient = new TableServiceClientBuilder()
.endpoint("https://myvault.azure.net/")
.credential(new AzureNamedKeyCredential("name", "key"))
.buildAsyncClient();
TableServiceClientBuilder| Modifier and Type | Method and Description |
|---|---|
Mono<TableAsyncClient> |
createTable(String tableName)
Creates a table within the Tables service.
|
Mono<TableAsyncClient> |
createTableIfNotExists(String tableName)
Creates a table within the Tables service if the table does not already exist.
|
Mono<com.azure.core.http.rest.Response<TableAsyncClient>> |
createTableIfNotExistsWithResponse(String tableName)
Creates a table within the Tables service if the table does not already exist.
|
Mono<com.azure.core.http.rest.Response<TableAsyncClient>> |
createTableWithResponse(String tableName)
Creates a table within the Tables service.
|
Mono<Void> |
deleteTable(String tableName)
Deletes a table within the Tables service.
|
Mono<com.azure.core.http.rest.Response<Void>> |
deleteTableWithResponse(String tableName)
Deletes a table within the Tables service.
|
String |
generateAccountSas(TableAccountSasSignatureValues tableAccountSasSignatureValues)
Generates an account SAS for the Azure Storage account using the specified
TableAccountSasSignatureValues. |
String |
getAccountName()
Gets the name of the account containing the table.
|
Mono<TableServiceProperties> |
getProperties()
Gets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin
Resource Sharing) rules.
|
Mono<com.azure.core.http.rest.Response<TableServiceProperties>> |
getPropertiesWithResponse()
Gets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin
Resource Sharing) rules.
|
String |
getServiceEndpoint()
Gets the endpoint for the Tables service.
|
TableServiceVersion |
getServiceVersion()
Gets the REST API version used by this client.
|
Mono<TableServiceStatistics> |
getStatistics()
Retrieves statistics related to replication for the account's Table service.
|
Mono<com.azure.core.http.rest.Response<TableServiceStatistics>> |
getStatisticsWithResponse()
Retrieves statistics related to replication for the account's Table service.
|
TableAsyncClient |
getTableClient(String tableName)
Gets a
TableAsyncClient instance for the table in the account with the provided tableName. |
com.azure.core.http.rest.PagedFlux<TableItem> |
listTables()
Lists all tables within the account.
|
com.azure.core.http.rest.PagedFlux<TableItem> |
listTables(ListTablesOptions options)
Lists tables using the parameters in the provided options.
|
Mono<Void> |
setProperties(TableServiceProperties tableServiceProperties)
Sets the properties of the account's Table service, including properties for Analytics and CORS (Cross-Origin
Resource Sharing) rules.
|
Mono<com.azure.core.http.rest.Response<Void>> |
setPropertiesWithResponse(TableServiceProperties tableServiceProperties)
Sets the properties of an account's Table service, including properties for Analytics and CORS (Cross-Origin
Resource Sharing) rules.
|
public String getAccountName()
public String getServiceEndpoint()
public TableServiceVersion getServiceVersion()
public String generateAccountSas(TableAccountSasSignatureValues tableAccountSasSignatureValues)
TableAccountSasSignatureValues.
Note: The client must be authenticated via AzureNamedKeyCredential.
See TableAccountSasSignatureValues for more information on how to construct an account SAS.
tableAccountSasSignatureValues - TableAccountSasSignatureValues.String representing the SAS query parameters.IllegalStateException - If this TableClient is not authenticated with an
AzureNamedKeyCredential.public TableAsyncClient getTableClient(String tableName)
TableAsyncClient instance for the table in the account with the provided tableName.tableName - The name of the table.TableAsyncClient instance for the table in the account with the provided tableName.IllegalArgumentException - If tableName is null or empty.public Mono<TableAsyncClient> createTable(String tableName)
Code Samples
Creates a table. Prints out the details of the created table.
tableServiceAsyncClient.createTable("myTable")
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(tableAsyncClient ->
System.out.printf("Table with name '%s' was created.", tableAsyncClient.getTableName()));
tableName - The name of the table to create.Mono containing a TableAsyncClient for the created table.IllegalArgumentException - If tableName is null or empty.TableServiceException - If a table with the same name already exists within the service.public Mono<com.azure.core.http.rest.Response<TableAsyncClient>> createTableWithResponse(String tableName)
Code Samples
Creates a table. Prints out the details of the HTTP response and the created table.
tableServiceAsyncClient.createTableWithResponse("myTable")
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(response ->
System.out.printf("Response successful with status code: %d. Table with name '%s' was created.",
response.getStatusCode(), response.getValue().getTableName()));
tableName - The name of the table to create.Mono containing the HTTP response that in turn contains a
TableAsyncClient for the created table.IllegalArgumentException - If tableName is null or empty.TableServiceException - If a table with the same name already exists within the service.public Mono<TableAsyncClient> createTableIfNotExists(String tableName)
Code Samples
Creates a table if it does not already exist. Prints out the details of the created table.
tableServiceAsyncClient.createTableIfNotExists("myTable")
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(tableAsyncClient ->
System.out.printf("Table with name '%s' was created.", tableAsyncClient.getTableName()));
tableName - The name of the table to create.Mono containing a TableAsyncClient for the created table.IllegalArgumentException - If tableName is null or empty.public Mono<com.azure.core.http.rest.Response<TableAsyncClient>> createTableIfNotExistsWithResponse(String tableName)
Code Samples
Creates a table if it does not already exist. Prints out the details of the created table.
tableServiceAsyncClient.createTableIfNotExistsWithResponse("myTable")
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(response ->
System.out.printf("Response successful with status code: %d. Table with name '%s' was created.",
response.getStatusCode(), response.getValue().getTableName()));
tableName - The name of the table to create.Mono containing the HTTP response that in turn contains a
TableAsyncClient for the created table.IllegalArgumentException - If tableName is null or empty.public Mono<Void> deleteTable(String tableName)
Code Samples
Deletes a table.
String tableName = "myTable";
tableServiceAsyncClient.deleteTable(tableName)
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(unused ->
System.out.printf("Table with name '%s' was deleted.", tableName));
tableName - The name of the table to delete.Mono.IllegalArgumentException - If tableName is null or empty.TableServiceException - If the request is rejected by the service.public Mono<com.azure.core.http.rest.Response<Void>> deleteTableWithResponse(String tableName)
Code Samples
Deletes a table.
String myTableName = "myTable";
tableServiceAsyncClient.deleteTableWithResponse(myTableName)
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(response ->
System.out.printf("Response successful with status code: %d. Table with name '%s' was deleted.",
response.getStatusCode(), myTableName));
tableName - The name of the table to delete.Mono containing the HTTP response.IllegalArgumentException - If tableName is null or empty.TableServiceException - If the request is rejected by the service.public com.azure.core.http.rest.PagedFlux<TableItem> listTables()
Code Samples
Lists all tables. Prints out the details of the retrieved tables.
tableServiceAsyncClient.listTables().subscribe(tableItem ->
System.out.printf("Retrieved table with name '%s'.%n", tableItem.getName()));
PagedFlux containing all tables within the account.TableServiceException - If the request is rejected by the service.public com.azure.core.http.rest.PagedFlux<TableItem> listTables(ListTablesOptions options)
filter parameter in the options is set, only tables matching the filter will be returned. If the
top parameter is set, the maximum number of returned tables per page will be limited to that value.
Code Samples
Lists all tables that match the filter. Prints out the details of the retrieved tables.
ListTablesOptions options = new ListTablesOptions().setFilter("TableName eq 'myTable'");
tableServiceAsyncClient.listTables(options).subscribe(tableItem ->
System.out.printf("Retrieved table with name '%s'.%n", tableItem.getName()));
options - The filter and top OData query options to apply to this operation.PagedFlux containing matching tables within the account.IllegalArgumentException - If one or more of the OData query options in options is malformed.TableServiceException - If the request is rejected by the service.public Mono<TableServiceProperties> getProperties()
This operation is only supported on Azure Storage endpoints.
Code Samples
Gets the properties of the account's Table service.
tableServiceAsyncClient.getProperties()
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(properties -> System.out.print("Retrieved service properties successfully."));
Mono containing the properties of the account's Table service.TableServiceException - If the request is rejected by the service.public Mono<com.azure.core.http.rest.Response<TableServiceProperties>> getPropertiesWithResponse()
This operation is only supported on Azure Storage endpoints.
Code Samples
Gets the properties of the account's Table service. Prints out the details of the
HTTP response.
tableServiceAsyncClient.getPropertiesWithResponse()
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(response ->
System.out.printf("Retrieved service properties successfully with status code: %d.",
response.getStatusCode()));
Mono containing the HTTP response that in turn contains the
properties of the account's Table service.TableServiceException - If the request is rejected by the service.public Mono<Void> setProperties(TableServiceProperties tableServiceProperties)
This operation is only supported on Azure Storage endpoints.
Code Samples
Sets the properties of the account's Table service.
TableServiceProperties properties = new TableServiceProperties()
.setHourMetrics(new TableServiceMetrics()
.setVersion("1.0")
.setEnabled(true))
.setLogging(new TableServiceLogging()
.setAnalyticsVersion("1.0")
.setReadLogged(true)
.setRetentionPolicy(new TableServiceRetentionPolicy()
.setEnabled(true)
.setDaysToRetain(5)));
tableServiceAsyncClient.setProperties(properties)
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(unused -> System.out.print("Set service properties successfully."));
tableServiceProperties - The TableServiceProperties to set.Mono.TableServiceException - If the request is rejected by the service.public Mono<com.azure.core.http.rest.Response<Void>> setPropertiesWithResponse(TableServiceProperties tableServiceProperties)
This operation is only supported on Azure Storage endpoints.
Code Samples
Sets the properties of the account's Table service. Prints out the details of the
HTTP response.
TableServiceProperties myProperties = new TableServiceProperties()
.setHourMetrics(new TableServiceMetrics()
.setVersion("1.0")
.setEnabled(true))
.setLogging(new TableServiceLogging()
.setAnalyticsVersion("1.0")
.setReadLogged(true)
.setRetentionPolicy(new TableServiceRetentionPolicy()
.setEnabled(true)
.setDaysToRetain(5)));
tableServiceAsyncClient.setPropertiesWithResponse(myProperties)
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(response ->
System.out.printf("Retrieved service properties successfully with status code: %d.",
response.getStatusCode()));
tableServiceProperties - The TableServiceProperties to set.Mono containing the HTTP response.TableServiceException - If the request is rejected by the service.public Mono<TableServiceStatistics> getStatistics()
This operation is only supported on Azure Storage endpoints.
Code Samples
Gets the replication statistics of the account's Table service.
tableServiceAsyncClient.getStatistics()
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(statistics -> System.out.print("Retrieved service statistics successfully."));
Mono containing statistics for the account's Table service.TableServiceException - If the request is rejected by the service.public Mono<com.azure.core.http.rest.Response<TableServiceStatistics>> getStatisticsWithResponse()
This operation is only supported on Azure Storage endpoints.
Code Samples
Gets the replication statistics of the account's Table service. Prints out the details of the
HTTP response.
tableServiceAsyncClient.getStatisticsWithResponse()
.contextWrite(Context.of("key1", "value1", "key2", "value2"))
.subscribe(response ->
System.out.printf("Retrieved service statistics successfully with status code: %d.",
response.getStatusCode()));
Mono containing the HTTP response that in turn contains
statistics for the account's Table service.TableServiceException - If the request is rejected by the service.Copyright © 2021 Microsoft Corporation. All rights reserved.