MVFC.Aspire.Helpers.GcpBigtable
13.1.0
dotnet add package MVFC.Aspire.Helpers.GcpBigtable --version 13.1.0
NuGet\Install-Package MVFC.Aspire.Helpers.GcpBigtable -Version 13.1.0
<PackageReference Include="MVFC.Aspire.Helpers.GcpBigtable" Version="13.1.0" />
<PackageVersion Include="MVFC.Aspire.Helpers.GcpBigtable" Version="13.1.0" />
<PackageReference Include="MVFC.Aspire.Helpers.GcpBigtable" />
paket add MVFC.Aspire.Helpers.GcpBigtable --version 13.1.0
#r "nuget: MVFC.Aspire.Helpers.GcpBigtable, 13.1.0"
#:package MVFC.Aspire.Helpers.GcpBigtable@13.1.0
#addin nuget:?package=MVFC.Aspire.Helpers.GcpBigtable&version=13.1.0
#tool nuget:?package=MVFC.Aspire.Helpers.GcpBigtable&version=13.1.0
MVFC.Aspire.Helpers.GcpBigtable
Google Cloud Bigtable emulator integration for .NET Aspire, with additive table provisioning and repeatable binary seeds.
Motivation
Local Bigtable clients need an emulator endpoint, tables and column families before application startup. This helper declares those requirements in the AppHost and exposes an explicit initialization wait for consumers that require seeded data.
Overview
AddGcpBigtableregisters the official emulator and a TCP health check.WithBigtableConfigscreates missing tables and adds missing column families. Existing families and data are preserved.WithDataSeedwrites binary row keys, qualifiers and values in batches of up to 100 rows.WithReferenceinjects the SDK environment variable and named connection string.WaitForInitializationblocks consumer startup until transport readiness, provisioning and seed completion.
Compatible Images
The default is gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators, pinned to the digest in BigtableDefaults.cs. The emulator listens on container port 8086. Linux containers are required. Override the image with WithDockerImage(image, tag); changing the tag clears the default digest. A digest identifies the image; it does not guarantee security or support.
Project Structure
- Models: table and seed declarations for tables and binary seed cells.
- Resources: Aspire container and connection expression.
- Processors: validation, additive provisioning and seed execution.
- Annotations: shared initialization and consumer references.
- HealthChecks: TCP connectivity probe.
Installation
dotnet add package MVFC.Aspire.Helpers.GcpBigtable
Library assets target .NET 9, 10 and 11. .NET 9 uses Aspire 13.6.5; .NET 10/11 use Aspire 17. A modern path-based AppHost also references Aspire.Hosting.Dotnet 17.0.0. See the compatibility matrix.
Usage
Add namespaces to the AppHost's global usings:
global using Google.Protobuf;
global using MVFC.Aspire.Helpers.GcpBigtable;
global using MVFC.Aspire.Helpers.GcpBigtable.Models;
Configure resources before building the application:
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddDotnetProject("api", "../MyApi/MyApi.csproj");
var bigtable = builder.AddGcpBigtable("bigtable")
.WithBigtableConfigs(new BigtableConfig("test-project", "dev-instance",
new BigtableTableConfig("users", "profile")))
.WithDataSeed(new BigtableSeed("test-project", "dev-instance", "users",
new BigtableSeedRow(ByteString.CopyFromUtf8("alice"),
new BigtableSeedCell("profile", ByteString.CopyFromUtf8("name"),
ByteString.CopyFromUtf8("Alice")))))
.WithConfigurationTimeout(60);
api.WithReference(bigtable).WaitForInitialization(bigtable);
await builder.Build().RunAsync();
Tables and seeds may be added before or after references/waits, but must be finalized before startup. Repeated table declarations merge their families. A seed destination must be declared, including its column families. Invalid declarations and conflicting values for the same cell version fail before remote mutation.
SDK compatibility
WithReference injects BIGTABLE_EMULATOR_HOST=host:port and ConnectionStrings__<resource-name>=host:port. The helper does not mutate process environment variables and does not invent SDK project/instance variables. Configure project, instance and table identifiers in your application.
The .NET SDK ignores emulator environment variables unless emulator detection is enabled. In the consuming API, reference Google.Cloud.Bigtable.V2 and use:
var client = new BigtableClientBuilder
{
EmulatorDetection = EmulatorDetection.EmulatorOnly,
}.Build();
var table = TableName.FromProjectInstanceTable("test-project", "dev-instance", "users");
var row = await client.ReadRowAsync(table, "alice");
BigtableClientBuilder is in Google.Cloud.Bigtable.V2, EmulatorDetection in Google.Api.Gax and TableName in Google.Cloud.Bigtable.Common.V2. Use aliases when other SDKs expose types with the same name. The injected named connection can also supply an explicitly configured endpoint with insecure channel credentials for local clients.
Each consumer can use one SDK environment endpoint; referencing a second emulator from the same consumer throws rather than silently replacing the first. Multiple consumers may reference the same emulator. To access multiple emulators from one application, configure separate clients explicitly from named connections rather than using this environment-based WithReference overload.
Readiness, cancellation and seed semantics
WaitFor(bigtable) proves TCP readiness only. WithReference supplies configuration and does not add a startup wait. WaitForInitialization(bigtable) adds the dependency and requires successful initialization. Initialization also starts when the emulator becomes ready, even without consumers. Never create a dependency cycle between the emulator and a waiting consumer.
One task is shared per resource and AppHost lifetime. All waiting consumers see the same result. Canceling a consumer wait does not cancel shared work; application shutdown does. Failures remain recorded and are not automatically retried by another consumer. The default 60-second shared deadline covers endpoint resolution, client construction, provisioning and seed execution. SDK-level transient retry policies remain in effect within that deadline.
Seeds use explicit cell timestamps: default 0 microseconds, with nonnegative, millisecond-aligned values supported. Replaying the same row/family/qualifier/timestamp replaces that cell version instead of creating a new one. Different timestamps deliberately create versions. Replaying seeds may overwrite changes to those same seeded cells. Keys are 1–4096 bytes; empty qualifiers and values are supported. Empty rows are skipped. Batches are not transactional; a failure can leave partial writes. Existing tables, families, rows and versions outside the declaration are never deleted.
Emulator limitations
The official emulator stores data in memory and loses it when stopped. No persistence volume API is offered. It does not reproduce production IAM, TLS, replication, backups, garbage collection or performance. Project and instance identifiers scope resource paths; the helper does not create cloud instances or clusters. Verify cloud-dependent behavior separately. See Google's emulator guide and .NET emulator detection.
Playground and tests
The AppHost declares test-project/dev-instance/users, the profile family and Alice/Bob seeds. The HTTP collection exercises readiness, seed reads, prefix listing, writes, overwrite, deletion and missing rows using a unique key. The playground demonstrates UTF-8 values; the helper accepts binary data.
Run dotnet cake from the repository root for the existing build, unit/integration tests and coverage report. A running container runtime is required. The tests cover configuration errors, cancellation, batching and shared initialization; integration tests verify real emulator provisioning, seed replay, isolation and API CRUD.
License
Licensed under Apache 2.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Aspire.Hosting (>= 17.0.0)
- Google.Cloud.Bigtable.Admin.V2 (>= 3.36.0)
- Google.Cloud.Bigtable.V2 (>= 3.33.0)
- MessagePack (>= 3.1.12)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.15)
-
net11.0
- Aspire.Hosting (>= 17.0.0)
- Google.Cloud.Bigtable.Admin.V2 (>= 3.36.0)
- Google.Cloud.Bigtable.V2 (>= 3.33.0)
- MessagePack (>= 3.1.12)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 11.0.0)
-
net9.0
- Aspire.Hosting (= 13.6.5)
- Google.Cloud.Bigtable.Admin.V2 (>= 3.36.0)
- Google.Cloud.Bigtable.V2 (>= 3.33.0)
- MessagePack (>= 3.1.12)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 13.1.0 | 50 | 11/29/2026 |