Note:
This documentation is for version3.23.0of the library.
Some samples may not work with other versions.
Installation
Install theGoogle.Cloud.Bigtable.V2package from NuGet. Add it to
your project in the normal way (for example by right-clicking on the
project in Visual Studio and choosing "Manage NuGet Packages...").
Authentication
When running on Google Cloud, no action needs to be taken to authenticate.
Otherwise, the simplest way of authenticating your API calls is to
set up Application Default Credentials.
The credentials will automatically be used to authenticate. SeeSet up Application Default Credentialsfor more details.
Getting started
Common operations are exposed via theBigtableClientclass.
Sample code
BigtableClient client = BigtableClient.Create();
TableName tableName = new TableName(projectId, instanceId, tableId);
// Insert a row with some cells into the table
await client.MutateRowAsync(
tableName,
"user12345",
Mutations.SetCell(
familyName: "Score",
columnQualifier: "Level 1",
value: 456),
Mutations.SetCell(
familyName: "metrics",
columnQualifier: "Level 1 - total time",
value: 12000));
// Read the row back from the table, but only the latest cell values
// from the 'Score' column family
Row row = await client.ReadRowAsync(
tableName,
"user12345",
filter: RowFilters.Chain(
RowFilters.FamilyNameExact("Score"),
RowFilters.CellsPerColumnLimit(1)));
foreach (Family family in row.Families)
{
string familyName = family.Name;
Console.WriteLine($"Family: {familyName}");
foreach (Column column in family.Columns)
{
BigtableByteString columnQualifier = column.Qualifier;
BigtableByteString cellValue = column.Cells[0].Value;
Console.WriteLine(
$"\tColumn: {(string)columnQualifier}, Value: {(long)cellValue}");
}
}
Client life-cycle management
By default, clients share an internally managed Grpc.Gcp.GcpCallInvoker to
establish gRPC channels with the Bigtable service using default credentials.
This class allows for multiple channels to be used concurrently and
load-balances requests and streams among them. BigtableClient instances are
intended to be ephermal and will reuse an existing GcpCallInvoker instance
behind the scenes where possible.
Note that this reuse is dependent upon the settings which control the usage of
the GcpCallInvoker instance being identical. Accidentally using different settings
when creating different clients could result in unintended performance degredation
as setting up a new GcpCallInvoker is expensive compared to creating a new
BigtableClient.
// client1 and client3 will share the same GcpCallInvoker, since they both
// use the same default settings. This means they will use the same shared
// set of gRPC channels to the Bigtable service.
// client2 and client4 will share a different GcpCallInvoker, since they both
// use the same custom MaxChannels/PreferredMaxStreamsPerChannel settings.
BigtableServiceApiSettings settings1 = BigtableServiceApiSettings.GetDefault();
BigtableClient client1 = new BigtableClientBuilder { Settings = settings1 }.Build();
BigtableServiceApiSettings settings2 = new BigtableServiceApiSettings
{
MaxChannels = 10,
PreferredMaxStreamsPerChannel = 4
};
BigtableClient client2 = new BigtableClientBuilder { Settings = settings2 }.Build();
BigtableServiceApiSettings settings3 = BigtableServiceApiSettings.GetDefault();
BigtableClient client3 = new BigtableClientBuilder { Settings = settings3 }.Build();
BigtableServiceApiSettings settings4 = new BigtableServiceApiSettings
{
MaxChannels = 10,
PreferredMaxStreamsPerChannel = 4
};
BigtableClient client4 = new BigtableClientBuilder { Settings = settings4 }.Build();
// client5 will not share a GcpCallInvoker with any of the other clients, since
// its MaxChannels/PreferredMaxStreamsPerChannel settings differ from the others.
BigtableServiceApiSettings settings5 = new BigtableServiceApiSettings
{
MaxChannels = 15,
PreferredMaxStreamsPerChannel = 4
};
BigtableClient client5 = new BigtableClientBuilder { Settings = settings5 }.Build();
Non-default credentials
If you would like to create clients which share a GcpCallInvoker but do not
use the default credentials, this can easily be done by manually creating a
GcpCallInvoker and using Bigtable's default endpoint and settings.
// Create a client from a custom credentials and a GcpCallInvoker that has
// non-default gRPC stream/channel options.
// The easiest way of creating a GcpCallInvoker is to use a new
// BigtableServiceApiClientBuilder just to create the call invoker,
// then remember the call invoker to set it in other builders.
// Note: the GcpCallInvoker should be long-lived while the BigtableClient
// instances can be ephemeral and each use the same call invoker.
BigtableServiceApiSettings settings = new BigtableServiceApiSettings
{
MaxChannels = 10,
PreferredMaxStreamsPerChannel = 4
};
GcpCallInvoker callInvoker = new BigtableServiceApiClientBuilder
{
Settings = settings,
ChannelCredentials = credentials,
}.CreateGcpCallInvoker();
// These will share the same set of channels to the Bigtable service.
BigtableClient client1 = new BigtableClientBuilder
{
CallInvoker = callInvoker,
Settings = settings
}.Build();
// ...
BigtableClient client2 = new BigtableClientBuilder
{
CallInvoker = callInvoker,
Settings = settings
}.Build();
// ...
await callInvoker.ShutdownAsync();
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThe \u003ccode\u003eGoogle.Cloud.Bigtable.V2\u003c/code\u003e library is a .NET client for the Google Bigtable API, with the current documentation focusing on version 3.17.0.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication is streamlined on Google Cloud, and for other environments, Application Default Credentials are the recommended method.\u003c/p\u003e\n"],["\u003cp\u003eThe primary interface for common operations is the \u003ccode\u003eBigtableClient\u003c/code\u003e class.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eBigtableClient\u003c/code\u003e instances share a \u003ccode\u003eGcpCallInvoker\u003c/code\u003e for gRPC channels by default, and using identical settings ensures reuse, whereas custom settings will result in a new \u003ccode\u003eGcpCallInvoker\u003c/code\u003e being created, which is resource intensive.\u003c/p\u003e\n"],["\u003cp\u003eYou can create \u003ccode\u003eBigtableClient\u003c/code\u003e with custom credentials by manually creating a \u003ccode\u003eGcpCallInvoker\u003c/code\u003e to use non-default credentials.\u003c/p\u003e\n"]]],[],null,["Version latestkeyboard_arrow_down\n\n- [3.23.0 (latest)](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest)\n- [3.22.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.22.0)\n- [3.21.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.21.0)\n- [3.20.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.20.0)\n- [3.19.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.19.0)\n- [3.18.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.18.0)\n- [3.17.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.17.0)\n- [3.16.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.16.0)\n- [3.15.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.15.0)\n- [3.14.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.14.0)\n- [3.13.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.13.0)\n- [3.12.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.12.0)\n- [3.11.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.11.0)\n- [3.10.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.10.0)\n- [3.9.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.9.0)\n- [3.8.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.8.0)\n- [3.7.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.7.0)\n- [3.6.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.6.0)\n- [3.5.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.5.0)\n- [3.4.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.4.0)\n- [3.3.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.3.0)\n- [3.2.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.2.0)\n- [3.1.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.1.0)\n- [3.0.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/3.0.0)\n- [2.6.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/2.6.0)\n- [2.5.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/2.5.0)\n- [2.4.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/2.4.0)\n- [2.3.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/2.3.0)\n- [2.2.0](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/2.2.0) \n\nGoogle.Cloud.Bigtable.V2\n========================\n\n`Google.Cloud.Bigtable.V2` is a.NET client library for the [Google Bigtable API](https://cloud.google.com/bigtable/).\n\nNote:\nThis documentation is for version `3.23.0` of the library.\nSome samples may not work with other versions.\n\nInstallation\n------------\n\nInstall the `Google.Cloud.Bigtable.V2` package from NuGet. Add it to\nyour project in the normal way (for example by right-clicking on the\nproject in Visual Studio and choosing \"Manage NuGet Packages...\").\n\nAuthentication\n--------------\n\nWhen running on Google Cloud, no action needs to be taken to authenticate.\n\nOtherwise, the simplest way of authenticating your API calls is to\nset up Application Default Credentials.\nThe credentials will automatically be used to authenticate. See\n[Set up Application Default Credentials](https://cloud.google.com/docs/authentication/provide-credentials-adc) for more details.\n\nGetting started\n---------------\n\nCommon operations are exposed via the\n[BigtableClient](/dotnet/docs/reference/Google.Cloud.Bigtable.V2/latest/Google.Cloud.Bigtable.V2.BigtableClient)\nclass.\n\nSample code\n-----------\n\n BigtableClient client = BigtableClient.Create();\n TableName tableName = new TableName(projectId, instanceId, tableId);\n\n // Insert a row with some cells into the table\n await client.MutateRowAsync(\n tableName,\n \"user12345\",\n Mutations.SetCell(\n familyName: \"Score\",\n columnQualifier: \"Level 1\",\n value: 456),\n Mutations.SetCell(\n familyName: \"metrics\",\n columnQualifier: \"Level 1 - total time\",\n value: 12000));\n\n // Read the row back from the table, but only the latest cell values\n // from the 'Score' column family\n Row row = await client.ReadRowAsync(\n tableName,\n \"user12345\",\n filter: RowFilters.Chain(\n RowFilters.FamilyNameExact(\"Score\"),\n RowFilters.CellsPerColumnLimit(1)));\n\n foreach (Family family in row.Families)\n {\n string familyName = family.Name;\n Console.WriteLine($\"Family: {familyName}\");\n\n foreach (Column column in family.Columns)\n {\n BigtableByteString columnQualifier = column.Qualifier;\n BigtableByteString cellValue = column.Cells[0].Value;\n Console.WriteLine(\n $\"\\tColumn: {(string)columnQualifier}, Value: {(long)cellValue}\");\n }\n }\n\nClient life-cycle management\n----------------------------\n\nBy default, clients share an internally managed Grpc.Gcp.GcpCallInvoker to\nestablish gRPC channels with the Bigtable service using default credentials.\nThis class allows for multiple channels to be used concurrently and\nload-balances requests and streams among them. BigtableClient instances are\nintended to be ephermal and will reuse an existing GcpCallInvoker instance\nbehind the scenes where possible.\n\nNote that this reuse is dependent upon the settings which control the usage of\nthe GcpCallInvoker instance being identical. Accidentally using different settings\nwhen creating different clients could result in unintended performance degredation\nas setting up a new GcpCallInvoker is expensive compared to creating a new\nBigtableClient. \n\n // client1 and client3 will share the same GcpCallInvoker, since they both\n // use the same default settings. This means they will use the same shared\n // set of gRPC channels to the Bigtable service.\n // client2 and client4 will share a different GcpCallInvoker, since they both\n // use the same custom MaxChannels/PreferredMaxStreamsPerChannel settings.\n BigtableServiceApiSettings settings1 = BigtableServiceApiSettings.GetDefault();\n BigtableClient client1 = new BigtableClientBuilder { Settings = settings1 }.Build();\n\n BigtableServiceApiSettings settings2 = new BigtableServiceApiSettings\n {\n MaxChannels = 10,\n PreferredMaxStreamsPerChannel = 4\n };\n BigtableClient client2 = new BigtableClientBuilder { Settings = settings2 }.Build();\n\n BigtableServiceApiSettings settings3 = BigtableServiceApiSettings.GetDefault();\n BigtableClient client3 = new BigtableClientBuilder { Settings = settings3 }.Build();\n\n BigtableServiceApiSettings settings4 = new BigtableServiceApiSettings\n {\n MaxChannels = 10,\n PreferredMaxStreamsPerChannel = 4\n };\n BigtableClient client4 = new BigtableClientBuilder { Settings = settings4 }.Build();\n\n // client5 will not share a GcpCallInvoker with any of the other clients, since\n // its MaxChannels/PreferredMaxStreamsPerChannel settings differ from the others.\n BigtableServiceApiSettings settings5 = new BigtableServiceApiSettings\n {\n MaxChannels = 15,\n PreferredMaxStreamsPerChannel = 4\n };\n BigtableClient client5 = new BigtableClientBuilder { Settings = settings5 }.Build();\n\nNon-default credentials\n-----------------------\n\nIf you would like to create clients which share a GcpCallInvoker but do not\nuse the default credentials, this can easily be done by manually creating a\nGcpCallInvoker and using Bigtable's default endpoint and settings. \n\n // Create a client from a custom credentials and a GcpCallInvoker that has\n // non-default gRPC stream/channel options.\n // The easiest way of creating a GcpCallInvoker is to use a new\n // BigtableServiceApiClientBuilder just to create the call invoker,\n // then remember the call invoker to set it in other builders.\n // Note: the GcpCallInvoker should be long-lived while the BigtableClient\n // instances can be ephemeral and each use the same call invoker.\n BigtableServiceApiSettings settings = new BigtableServiceApiSettings\n {\n MaxChannels = 10,\n PreferredMaxStreamsPerChannel = 4\n };\n GcpCallInvoker callInvoker = new BigtableServiceApiClientBuilder\n {\n Settings = settings,\n ChannelCredentials = credentials,\n }.CreateGcpCallInvoker();\n\n // These will share the same set of channels to the Bigtable service.\n BigtableClient client1 = new BigtableClientBuilder\n {\n CallInvoker = callInvoker,\n Settings = settings\n }.Build();\n // ...\n BigtableClient client2 = new BigtableClientBuilder\n {\n CallInvoker = callInvoker,\n Settings = settings\n }.Build();\n // ...\n\n await callInvoker.ShutdownAsync();"]]