azure-docs-sdk-java/docs-ref-autogen/com.azure.data.tables.yml

21 строка
17 KiB
YAML

### YamlMime:JavaPackage
uid: "com.azure.data.tables"
fullName: "com.azure.data.tables"
name: "com.azure.data.tables"
summary: "Azure Tables is a NoSQL key-value storage service offered by Microsoft Azure, which provides a highly scalable and cost-effective solution for storing structured data."
classes:
- "com.azure.data.tables.TableAsyncClient"
- "com.azure.data.tables.TableAzureNamedKeyCredentialPolicy"
- "com.azure.data.tables.TableClient"
- "com.azure.data.tables.TableClientBuilder"
- "com.azure.data.tables.TableScrubEtagPolicy"
- "com.azure.data.tables.TableServiceAsyncClient"
- "com.azure.data.tables.TableServiceClient"
- "com.azure.data.tables.TableServiceClientBuilder"
enums:
- "com.azure.data.tables.TableServiceVersion"
desc: "Azure Tables is a NoSQL key-value storage service offered by Microsoft Azure, which provides a highly scalable and cost-effective solution for storing structured data. It is a fully managed service that is designed to handle large volumes of structured data in a distributed environment, with low latency and high availability. Azure Tables stores data in tables, which are schema-less and can contain any type of data. Each table can have a partition key and a row key, which together form a unique primary key that can be used to retrieve individual records. This enables fast, efficient querying of data, especially when combined with Azure's indexing and query features.\n\nThe Azure Tables client library enables Java developers to easily interact with Azure Tables Storage Service from their Java applications. This library provides a set of APIs that abstract the low-level details of working with the Azure Tables Storage Service and allows developers to perform common operations such as creating tables, inserting, updating and deleting entities, querying data, and managing access control on tables and entities. The library supports both Azure Storage and Azure Cosmos tables. It offers both synchronous and asynchronous programming models. It also provides features such as retries, automatic pagination, and parallelism to enable efficient and reliable interactions with Azure Tables Storage Service.\n\n## Getting Started ##\n\n### Prerequisites ###\n\nThe client library package requires the following:\n\n * Java 8 or later\n * An Azure subscription\n * An existing Azure Storage or Azure Cosmos account\n\n--------------------\n\n### Authenticate a Client ###\n\nIn order to build a valid table client or table service client, you will need to authenticate the client using an accepted method of authentication. The supported forms of authentication are:\n\n * [Connection String][]\n * [Shared Key][]\n * [Shared Access Signature (SAS)][Shared Access Signature _SAS]\n * [Token Credential][]\n\nSee client builder class documentation <xref uid=\"com.azure.data.tables.TableServiceClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClientBuilder\"></xref> and <xref uid=\"com.azure.data.tables.TableClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClientBuilder\"></xref> for examples of authenticating a client.\n\nFor more information on authentication types, see [the identity documentation][].\n\n*Table service clients utilize their authentication information to create table clients. Table clients created via a table service client will inherit the authentication information of the table service client.*\n\n--------------------\n\n### Overview ###\n\nThe <xref uid=\"com.azure.data.tables.TableServiceClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient\"></xref> and <xref uid=\"com.azure.data.tables.TableServiceAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceAsyncClient\"></xref> provide access to the tables within an Azure Storage or Azure Cosmos account. A table service client can create, list, and delete tables. It also provides access to a table client that can be used to perform CRUD operations on entities within a table. You can instantiate a table service client using an instance of <xref uid=\"com.azure.data.tables.TableServiceClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClientBuilder\"></xref>.\n\nThe <xref uid=\"com.azure.data.tables.TableClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient\"></xref> and <xref uid=\"com.azure.data.tables.TableAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.tables.TableAsyncClient\"></xref> provide access to a specific table within an Azure Storage or Azure Cosmos account. A table client can be used to perform CRUD and query operations on entities within a table. Table clients can also create\\* new tables and delete the table they reference from the Azure Storage or Cosmos acount. An instance of a table client can be returned via a table service client or can be instantiated using an instance of <xref uid=\"com.azure.data.tables.TableClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClientBuilder\"></xref>.\n\n*\\* Tables created from a table client do not return a new TableClient instance. Table client instances cannot change the table they reference. To reference the newly created table, a new table client instance must be instantiated referencing the table.*\n\nSee methods in client level class below to explore all capabilities the library provides.\n\n--------------------\n\n## Table Service Client Usage ##\n\n### Create a <xref uid=\"com.azure.data.tables.TableServiceClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient\"></xref> using a <xref uid=\"com.azure.data.tables.TableServiceClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClientBuilder\"></xref> ###\n\nThe <xref uid=\"com.azure.data.tables.TableServiceClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient\"></xref> and <xref uid=\"com.azure.data.tables.TableServiceAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceAsyncClient\"></xref> both provide access to the tables within an Azure Storage or Azure Cosmos account. A table service client can create, list, and delete tables. It also provides access to a table client that can be used to perform CRUD operations on entities within a table. You can instantiate a table service client using an instance of <xref uid=\"com.azure.data.tables.TableServiceClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClientBuilder\"></xref>.\n\nHere's an example of creating a synchronous table service client using the <xref uid=\"com.azure.data.tables.TableServiceClientBuilder.buildClient()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.tables.TableServiceClientBuilder#buildClient()\"></xref> TableServiceClientBuilder buildClient\\} method:\n\n```java\nTableServiceClient tableServiceClient = new TableServiceClientBuilder()\n .connectionString(\"connectionstring\")\n .buildClient();\n```\n\n**Note:** To create an asynchronous table service client, call <xref uid=\"com.azure.data.tables.TableServiceClientBuilder.buildAsyncClient()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"buildAsyncClient()\"></xref> instead of <xref uid=\"com.azure.data.tables.TableServiceClientBuilder.buildClient()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"buildClient()\"></xref>.\n\n--------------------\n\n### Create a Table using <xref uid=\"com.azure.data.tables.TableServiceClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient\"></xref> ###\n\nThe <xref uid=\"com.azure.data.tables.TableServiceClient.createTable(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient createTable\"></xref> method can be used to create an new table within your Azure Storage or Azure Cosmos account.\n\nThe following example creates a table with the name \"tableName\".\n\n```java\ntableServiceClient.createTable(\"tableName\");\n```\n\n**Note:** For asynchronous sample, refer to <xref uid=\"com.azure.data.tables.TableServiceAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceAsyncClient\"></xref>\n\n--------------------\n\n### List Tables using <xref uid=\"com.azure.data.tables.TableServiceClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient\"></xref> ###\n\nThe <xref uid=\"com.azure.data.tables.TableServiceClient.listTables()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient listTables\"></xref> method can be used to list the tables that are within an Azure Storage or Azure Cosmos account.\n\nThe following example lists all the tables in the account without any filtering of Tables.\n\n```java\ntableServiceClient.listTables().forEach(table -> {\n String tableName = table.getName();\n System.out.println(\"Table name: \" + tableName);\n });\n```\n\n**Note:** For asynchronous sample, refer to <xref uid=\"com.azure.data.tables.TableServiceAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceAsyncClient\"></xref>\n\n--------------------\n\n### Delete a Table using <xref uid=\"com.azure.data.tables.TableServiceClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient\"></xref> ###\n\nThe <xref uid=\"com.azure.data.tables.TableServiceClient.deleteTable(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient deleteTable\"></xref> method can be used to delete a table that is within your Azure Storage or Azure Cosmos account.\n\nThe following example deletes a table with the name \"tableName\".\n\n```java\ntableServiceClient.deleteTable(\"tableName\");\n```\n\n**Note:** For asynchronous sample, refer to <xref uid=\"com.azure.data.tables.TableServiceAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceAsyncClient\"></xref>\n\n--------------------\n\n## Table Client Usage ##\n\nThe <xref uid=\"com.azure.data.tables.TableClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient\"></xref> and <xref uid=\"com.azure.data.tables.TableAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.tables.TableAsyncClient\"></xref> provide access to a specific table within an Azure Storage or Azure Cosmos account. A table client can be used to perform CRUD and query operations on entities within a table. Table clients can also create\\* new tables and delete the table they reference from the Azure Storage or Cosmos acount. An instance of a table client can be returned via a table service client or can be instantiated using an instance of <xref uid=\"com.azure.data.tables.TableClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClientBuilder\"></xref>.\n\n### Retrieve a <xref uid=\"com.azure.data.tables.TableClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient\"></xref> from a <xref uid=\"com.azure.data.tables.TableServiceClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceClient\"></xref> ###\n\nThe <xref uid=\"com.azure.data.tables.TableServiceClient.getTableClient(java.lang.String)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.tables.TableServiceClient#getTableClient(java.lang.String)\"></xref> TableServiceClient getTableClient\\} method can be used to retrieve a TableClient for a specified table that is stored within your Azure Storage or Azure Cosmos account.\n\nThe following example returns a table client for a table with the name \"tableName\".\n\n```java\nTableClient tableClient = tableServiceClient.getTableClient(\"tableName\");\n```\n\n**Note:** For asynchronous sample, refer to <xref uid=\"com.azure.data.tables.TableServiceAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableServiceAsyncClient\"></xref>\n\n--------------------\n\n### Create a <xref uid=\"com.azure.data.tables.TableClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient\"></xref> using a <xref uid=\"com.azure.data.tables.TableClientBuilder\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClientBuilder\"></xref> ###\n\nThe <xref uid=\"com.azure.data.tables.TableClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient\"></xref> and <xref uid=\"com.azure.data.tables.TableAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"com.azure.data.tables.TableAsyncClient\"></xref> provide access to a specific table within an Azure Storage or Azure Cosmos account. The <xref uid=\"com.azure.data.tables.TableClientBuilder.buildClient()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClientBuilder buildClient\"></xref> method can be used to create a <xref uid=\"com.azure.data.tables.TableClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient\"></xref>\n\nHere's an example of creating a TableClient using a builder:\n\n```java\nTableClient tableClient = new TableClientBuilder()\n .connectionString(\"connectionstring\")\n .tableName(\"tableName\")\n .buildClient();\n```\n\n**Note:** To create an TableAsyncClient, call <xref uid=\"com.azure.data.tables.TableClientBuilder.buildAsyncClient()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"buildAsyncClient()\"></xref> instead of <xref uid=\"com.azure.data.tables.TableClientBuilder.buildClient()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"buildClient()\"></xref>.\n\n--------------------\n\n### Create an Entity using <xref uid=\"com.azure.data.tables.TableClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient\"></xref> ###\n\nThe <xref uid=\"com.azure.data.tables.TableClient.createEntity(com.azure.data.tables.models.TableEntity)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient createEntity\"></xref> method can be used to create a table entity within a table in your Azure Storage or Azure Cosmos account.\n\nThe following example creates an entity with a partition key of \"partitionKey\" and a row key of \"rowKey\".\n\n```java\ntableClient.createEntity(new TableEntity(\"partitionKey\", \"rowKey\")\n .addProperty(\"property\", \"value\"));\n```\n\n**Note:** for asynchronous sample, refer to <xref uid=\"com.azure.data.tables.TableAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableAsyncClient\"></xref>\n\n--------------------\n\n### Update an Entity using <xref uid=\"com.azure.data.tables.TableClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient\"></xref> ###\n\nThe <xref uid=\"com.azure.data.tables.TableClient.updateEntity(com.azure.data.tables.models.TableEntity)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient updateEntity\"></xref> method can be used to update a table entity within a table in your Azure Storage or Azure Cosmos account.\n\nThe following example updates an entity with a partition key of \"partitionKey\" and a row key of \"rowKey\", adding an additional property with the name \"newProperty\" and the value \"newValue\".\n\n```java\nTableEntity entity = tableClient.getEntity(\"partitionKey\", \"rowKey\");\n entity.addProperty(\"newProperty\", \"newValue\");\n tableClient.updateEntity(entity);\n```\n\n**Note:** for asynchronous sample, refer to <xref uid=\"com.azure.data.tables.TableAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableAsyncClient\"></xref>\n\n--------------------\n\n### List Entities ###\n\nThe <xref uid=\"com.azure.data.tables.TableClient.listEntities()\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient listEntities\"></xref> method can be used to list the entities that are within a table in your Azure Storage or Azure Cosmos account.\n\nThe following example lists all entities in a table without any filtering.\n\n```java\ntableClient.listEntities().forEach(entity -> {\n String partitionKey = entity.getPartitionKey();\n String rowKey = entity.getRowKey();\n System.out.println(\"Partition key: \" + partitionKey + \", Row key: \" + rowKey);\n });\n```\n\n**Note:** for asynchronous sample, refer to <xref uid=\"com.azure.data.tables.TableAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableAsyncClient\"></xref>\n\n--------------------\n\n### Delete an Entity ###\n\nThe <xref uid=\"com.azure.data.tables.TableClient.deleteEntity(com.azure.data.tables.models.TableEntity)\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableClient deleteEntity\"></xref> method can be used to delete an entity that is within a table in your Azure Storage or Azure Cosmos account.\n\nThe following example deletes an entity with a partition key of \"partitionKey\" and a row key of \"rowKey\".\n\n```java\ntableClient.deleteEntity(\"partitionKey\", \"rowKey\");\n```\n\n**Note:** for asynchronous sample, refer to <xref uid=\"com.azure.data.tables.TableAsyncClient\" data-throw-if-not-resolved=\"false\" data-raw-source=\"TableAsyncClient\"></xref>\n\n\n[Connection String]: https://learn.microsoft.com/java/api/overview/azure/data-tables-readme?view=azure-java-stable#connection-string\n[Shared Key]: https://learn.microsoft.com/java/api/com.azure.core.credential.azurenamedkeycredential?view=azure-java-stable\n[Shared Access Signature _SAS]: https://learn.microsoft.com/java/api/com.azure.core.credential.azuresascredential?view=azure-java-stable\n[Token Credential]: https://learn.microsoft.com/java/api/com.azure.core.credential.tokencredential?view=azure-java-stable\n[the identity documentation]: https://learn.microsoft.com/azure/developer/java/sdk/identity"
metadata: {}
package: "com.azure.data.tables"
artifact: com.azure:azure-data-tables:12.4.4