![]() |
VOOZH | about |
dotnet add package Azure.Data.Tables --version 12.11.0
NuGet\Install-Package Azure.Data.Tables -Version 12.11.0
<PackageReference Include="Azure.Data.Tables" Version="12.11.0" />
<PackageVersion Include="Azure.Data.Tables" Version="12.11.0" />Directory.Packages.props
<PackageReference Include="Azure.Data.Tables" />Project file
paket add Azure.Data.Tables --version 12.11.0
#r "nuget: Azure.Data.Tables, 12.11.0"
#:package Azure.Data.Tables@12.11.0
#addin nuget:?package=Azure.Data.Tables&version=12.11.0Install as a Cake Addin
#tool nuget:?package=Azure.Data.Tables&version=12.11.0Install as a Cake Tool
Azure Table storage is a service that stores large amounts of structured NoSQL data in the cloud, providing a key/attribute store with a schema-less design.
Azure Cosmos DB provides a Table API for applications that are written for Azure Table storage that need premium capabilities like:
The Azure Tables client library can seamlessly target either Azure Table storage or Azure Cosmos DB table service endpoints with no code changes.
Source code | Package (NuGet) | API reference documentation | Samples | Change Log
Install the Azure Tables client library for .NET with NuGet:
dotnet add package Azure.Data.Tables
If you need to create either of these, you can use the Azure CLI.
Create a storage account mystorageaccount in resource group MyResourceGroup
in the subscription MySubscription in the West US region.
az storage account create -n mystorageaccount -g MyResourceGroup -l westus --subscription MySubscription
Create a Cosmos DB account MyCosmosDBDatabaseAccount in resource group MyResourceGroup
in the subscription MySubscription and a table named MyTableName in the account.
az cosmosdb create --name MyCosmosDBDatabaseAccount --capabilities EnableTable --resource-group MyResourceGroup --subscription MySubscription
az cosmosdb table create --name MyTableName --resource-group MyResourceGroup --account-name MyCosmosDBDatabaseAccount
Learn more about options for authentication (including Connection Strings, Shared Key, Shared Key Signatures, and TokenCredentials) in our samples.
TableServiceClient - Client that provides methods to interact at the Table Service level such as creating, listing, and deleting tablesTableClient - Client that provides methods to interact at an table entity level such as creating, querying, and deleting entities within a table.Table - Tables store data as collections of entities.Entity - Entities are similar to rows. An entity has a primary key and a set of properties. A property is a name value pair, similar to a column.Common uses of the Table service include:
We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.
Client options | Accessing the response | Long-running operations | Handling failures | Diagnostics | Mocking | Client lifetime
First, we need to construct a TableServiceClient.
// Construct a new "TableServiceClient using a TableSharedKeyCredential.
var serviceClient = new TableServiceClient(
new Uri(storageUri),
new TableSharedKeyCredential(accountName, storageAccountKey));
Next, we can create a new table.
// Create a new table. The TableItem class stores properties of the created table.
TableItem table = serviceClient.CreateTableIfNotExists(tableName);
Console.WriteLine($"The created table's name is {table.Name}.");
The set of existing Azure tables can be queries using an OData filter.
// Use the <see cref="TableServiceClient"> to query the service. Passing in OData filter strings is optional.
Pageable<TableItem> queryTableResults = serviceClient.Query(filter: $"TableName eq '{tableName}'");
Console.WriteLine("The following are the names of the tables in the query results:");
// Iterate the <see cref="Pageable"> in order to access queried tables.
foreach (TableItem table in queryTableResults)
{
Console.WriteLine(table.Name);
}
Individual tables can be deleted from the service.
// Deletes the table made previously.
serviceClient.DeleteTable(tableName);
To interact with table entities, we must first construct a TableClient.
// Construct a new <see cref="TableClient" /> using a <see cref="TableSharedKeyCredential" />.
var tableClient = new TableClient(
new Uri(storageUri),
tableName,
new TableSharedKeyCredential(accountName, storageAccountKey));
// Create the table in the service.
tableClient.Create();
Let's define a new TableEntity so that we can add it to the table.
// Make a dictionary entity by defining a <see cref="TableEntity">.
var tableEntity = new TableEntity(partitionKey, rowKey)
{
{ "Product", "Marker Set" },
{ "Price", 5.00 },
{ "Quantity", 21 }
};
Console.WriteLine($"{tableEntity.RowKey}: {tableEntity["Product"]} costs ${tableEntity.GetDouble("Price")}.");
Using the TableClient we can now add our new entity to the table.
// Add the newly created entity.
tableClient.AddEntity(tableEntity);
To inspect the set of existing table entities, we can query the table using an OData filter.
Pageable<TableEntity> queryResultsFilter = tableClient.Query<TableEntity>(filter: $"PartitionKey eq '{partitionKey}'");
// Iterate the <see cref="Pageable"> to access all queried entities.
foreach (TableEntity qEntity in queryResultsFilter)
{
Console.WriteLine($"{qEntity.GetString("Product")}: {qEntity.GetDouble("Price")}");
}
Console.WriteLine($"The query returned {queryResultsFilter.Count()} entities.");
If you prefer LINQ style query expressions, we can query the table using that syntax as well. To demonstrate this syntax, you'll need a strongly typed model such as the one below:
// Define a strongly typed entity by implementing the ITableEntity interface.
public class OfficeSupplyEntity : ITableEntity
{
public string Product { get; set; }
public double Price { get; set; }
public int Quantity { get; set; }
public string PartitionKey { get; set; }
public string RowKey { get; set; }
public DateTimeOffset? Timestamp { get; set; }
public ETag ETag { get; set; }
}
Given this model class definition, here is how you'd write a query:
double priceCutOff = 6.00;
Pageable<OfficeSupplyEntity> queryResultsLINQ = tableClient.Query<OfficeSupplyEntity>(ent => ent.Price >= priceCutOff);
If we no longer need our new table entity, it can be deleted.
// Delete the entity given the partition and row key.
tableClient.DeleteEntity(partitionKey, rowKey);
When using the Azure tables library, errors returned by the service are reported using the same HTTP status codes returned for REST API requests.
For example, if you try to create a table that already exists, a 409 error is returned, indicating "Conflict".
// Construct a new TableClient using a connection string.
var client = new TableClient(
connectionString,
tableName);
// Create the table if it doesn't already exist.
client.CreateIfNotExists();
// Now attempt to create the same table unconditionally.
try
{
client.Create();
}
catch (RequestFailedException ex) when (ex.Status == (int)HttpStatusCode.Conflict)
{
Console.WriteLine(ex.ToString());
}
The simplest way to see the logs is to enable the console logging. To create an Azure SDK log listener that outputs messages to console use AzureEventSourceListener.CreateConsoleLogger method.
// Setup a listener to monitor logged events.
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();
To learn more about other logging mechanisms see here.
Get started with our Table samples.
A list of currently known issues relating to Cosmos DB table endpoints can be found here.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Azure.Data.Tables:
| Package | Downloads |
|---|---|
|
Microsoft.Azure.DurableTask.AzureStorage
Azure Storage provider extension for the Durable Task Framework. |
|
|
Serilog.Sinks.AzureTableStorage
Serilog event sink that writes to Azure Table Storage over HTTP. |
|
|
Microsoft.Orleans.Clustering.AzureStorage
Microsoft Orleans clustering provider backed by Azure Table Storage |
|
|
TIKSN-Framework
TIKSN Framework is a .NET 10 application framework and utility library for building modular services, command-line tools, data-driven applications, and .NET MAUI apps. It includes dependency injection helpers, Autofac modules, repository, query repository, file repository, stream repository, pagination, unit-of-work abstractions, Entity Framework Core, Azure Table Storage, Azure Blob Storage, MongoDB, LiteDB, and RavenDB adapters, memory, distributed, and hybrid repository cache decorators, finance and money types, pricing models, currency conversion, central-bank foreign exchange providers, globalization, language and region localization resources, JSON, XML, MessagePack, custom binary serialization, Protocol Buffers-backed licensing schema support, license generation and signature services, shell and PowerShell application infrastructure, telemetry abstractions, correlation IDs, settings, known folders, network connectivity, antimalware abstractions, versioning, numbering, time period types, REST helpers, sitemap models, and platform-specific MAUI registrations. |
|
|
Microsoft.Orleans.Persistence.AzureStorage
Microsoft Orleans persistence providers backed by Azure Storage |
Showing the top 20 popular GitHub repositories that depend on Azure.Data.Tables:
| Repository | Stars |
|---|---|
|
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
|
|
|
dotnet/orleans
Cloud Native application framework for .NET
|
|
|
MassTransit/MassTransit
Distributed Application Framework for .NET
|
|
|
microsoft/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
|
|
|
ServiceStack/ServiceStack
Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
|
|
|
Azure/azure-powershell
Microsoft Azure PowerShell
|
|
|
Xabaril/AspNetCore.Diagnostics.HealthChecks
Enterprise HealthChecks for ASP.NET Core Diagnostics Package
|
|
|
testcontainers/testcontainers-dotnet
A library to support tests with throwaway instances of Docker containers for all compatible .NET Standard versions.
|
|
|
thomhurst/TUnit
A modern, fast and flexible .NET testing framework
|
|
|
microsoft/mcp
Catalog of official Microsoft MCP (Model Context Protocol) server implementations for AI-powered data access and tool integration
|
|
|
microsoft/onefuzz
A self-hosted Fuzzing-As-A-Service platform
|
|
|
thepirat000/Audit.NET
An extensible framework to audit executing operations in .NET
|
|
|
Azure/azure-functions-host
The host/runtime that powers Azure Functions
|
|
|
Azure/durabletask
Durable Task Framework allows users to write long running persistent workflows in C# using the async/await capabilities.
|
|
|
NuGet/NuGetGallery
NuGet Gallery is a package repository that powers https://www.nuget.org. Use this repo for reporting NuGet.org issues.
|
|
|
Azure/azure-mcp
The Azure MCP Server, bringing the power of Azure to your agents.
|
|
|
csharpfritz/csharp_with_csharpfritz
Show notes, slides, and samples from the CSharp with CSharpFritz show
|
|
|
mizrael/SuperSafeBank
Sample Event Sourcing implementation with .NET Core
|
|
|
DataDog/dd-trace-dotnet
.NET Client Library for Datadog APM
|
|
|
VedAstro/VedAstro
A non-profit, open source project to make Vedic Astrology easily available to all.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 12.11.0 | 21,692,141 | 5/6/2025 |
| 12.10.0 | 7,641,036 | 1/14/2025 |
| 12.9.1 | 14,017,568 | 9/17/2024 |
| 12.9.0 | 5,455,356 | 7/22/2024 |
| 12.8.3 | 15,910,975 | 2/6/2024 |
| 12.8.2 | 7,042,710 | 11/13/2023 |
| 12.8.1 | 3,898,115 | 8/16/2023 |
| 12.8.0 | 22,323,066 | 2/8/2023 |
| 12.7.1 | 4,607,273 | 11/15/2022 |
| 12.7.0 | 706,607 | 11/9/2022 |
| 12.7.0-beta.1 | 32,134 | 9/6/2022 |
| 12.6.1 | 9,079,332 | 7/7/2022 |
| 12.6.0 | 1,314,690 | 6/8/2022 |
| 12.6.0-beta.1 | 8,231 | 5/10/2022 |
| 12.5.0 | 3,526,657 | 3/10/2022 |
| 12.4.0 | 2,241,437 | 1/13/2022 |
| 12.3.0 | 5,522,315 | 11/9/2021 |
| 12.2.1 | 487,795 | 10/14/2021 |
| 12.2.0 | 1,424,160 | 9/8/2021 |
| 12.2.0-beta.1 | 12,150 | 8/10/2021 |