VOOZH about

URL: https://www.nuget.org/packages/MVFC.Aspire.Helpers.GcpSpanner/

⇱ NuGet Gallery | MVFC.Aspire.Helpers.GcpSpanner 9.0.3




👁 Image
MVFC.Aspire.Helpers.GcpSpanner 9.0.3

dotnet add package MVFC.Aspire.Helpers.GcpSpanner --version 9.0.3
 
 
NuGet\Install-Package MVFC.Aspire.Helpers.GcpSpanner -Version 9.0.3
 
 
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MVFC.Aspire.Helpers.GcpSpanner" Version="9.0.3" />
 
 
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MVFC.Aspire.Helpers.GcpSpanner" Version="9.0.3" />
 
Directory.Packages.props
<PackageReference Include="MVFC.Aspire.Helpers.GcpSpanner" />
 
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MVFC.Aspire.Helpers.GcpSpanner --version 9.0.3
 
 
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MVFC.Aspire.Helpers.GcpSpanner, 9.0.3"
 
 
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MVFC.Aspire.Helpers.GcpSpanner@9.0.3
 
 
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MVFC.Aspire.Helpers.GcpSpanner&version=9.0.3
 
Install as a Cake Addin
#tool nuget:?package=MVFC.Aspire.Helpers.GcpSpanner&version=9.0.3
 
Install as a Cake Tool
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

MVFC.Aspire.Helpers.GcpSpanner

🇧🇷

👁 CI
👁 codecov
👁 Platform
👁 NuGet Version
👁 NuGet Downloads

Helpers for integrating with Google Cloud Spanner in .NET Aspire projects, including support for the emulator.

Motivation

Working with Google Cloud Spanner locally usually means:

  • Spinning up an emulator container by hand.
  • Remembering ports, project IDs, instances, databases, and environment variables.
  • Manually creating instances and databases, and running DDL scripts.

With .NET Aspire you can define containers, but you still need to:

  • Configure the emulator image and its ports.
  • Keep emulator environment variables in sync across projects.
  • Define instances/databases in a consistent way before the application runs.

MVFC.Aspire.Helpers.GcpSpanner provides:

  • AddGcpSpanner(...) to start the emulator.
  • WithSpannerConfigs(...) to describe instances, databases, and execute DDLs in code.
  • WithReference(...) to wire projects to the emulator and inject connection configurations automatically.

Overview

This project facilitates the configuration and integration of Google Cloud Spanner in distributed .NET Aspire applications, providing extension methods to:

  • Add the Google Cloud Spanner emulator.
  • Configure instances and databases automatically upon startup.
  • Execute DDL statements right after database creation.
  • Properly inject the emulator host connection string for automatic detection by Spanner clients.

Spanner emulator advantages

  • Simulates Spanner databases locally for development and testing.
  • Allows testing schema changes and query executions without depending on Google Cloud infrastructure.
  • Facilitates development of robust data storage implementations.

Compatible Images

  • Emulator:
    • gcr.io/cloud-spanner-emulator/emulator (Default in Aspire helper)

Project Structure

  • : Helpers and extensions library for Spanner.

Features

  • Adds the Google Cloud Spanner emulator.
  • Creates instances and databases according to configuration.
  • Executes custom DDL statements upon provisioning.
  • Native gRPC port health checks ensure the emulator is fully ready before projects start consuming it.
  • Extension methods to facilitate AppHost configuration.

Installation

dotnet add package MVFC.Aspire.Helpers.GcpSpanner

Quick Aspire usage (AppHost)

using Aspire.Hosting;
using MVFC.Aspire.Helpers.GcpSpanner;
using MVFC.Aspire.Helpers.GcpSpanner.Models;

var builder = DistributedApplication.CreateBuilder(args);

var spannerConfig = new SpannerConfig(
 ProjectId: "test-project",
 InstanceId: "dev-instance",
 DatabaseId: "dev-db",
 DdlStatements:
 [
 """
 CREATE TABLE Users (
 UserId STRING(36) NOT NULL,
 Name STRING(256) NOT NULL,
 CreatedAt TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true)
 ) PRIMARY KEY (UserId)
 """
 ]);

var spanner = builder.AddGcpSpanner("gcp-spanner")
 .WithSpannerConfigs(spannerConfig)
 .WithWaitTimeout(30);

builder.AddProject<Projects.MVFC_Aspire_Helpers_Playground_Api>("api-example")
 .WithReference(spanner)
 .WaitFor(spanner);

await builder.Build().RunAsync();

Emulated Resources Configuration

SpannerConfig

Parameter Type Default Description
ProjectId string GCP project ID.
InstanceId string Instance ID.
DatabaseId string Database ID.
DdlStatements IReadOnlyList<string>? null Check DDL statements to run after DB creation.

Ports

  • gRPC Port: 9010

Provisioning diagram

sequenceDiagram
 participant Aspire as .NET Aspire
 participant Container as Spanner Emulator Container
 participant Configurator as Config Processor
 
 Aspire->>Container: Start container (gcr.io/cloud-spanner-emulator/emulator)
 Container-->>Aspire: Ready (gRPC port 9010 available)
 Aspire->>Configurator: Trigger OnResourceReady
 Configurator->>Container: Check/Create Instance
 Configurator->>Container: Check/Create Database
 Configurator->>Container: Execute DDLs
 Configurator-->>Aspire: Provisioning Completed
 Aspire->>App: Start App with SPANNER_EMULATOR_HOST

Public methods

  • AddGcpSpanner – adds the emulator container.
  • WithSpannerConfigs – configures instances, databases, and DDL scripts.
  • WithWaitTimeout – sets emulator startup delay timeout.
  • WithReference – wires projects to the emulator and sets the SPANNER_EMULATOR_HOST environment variable automatically.

Requirements

  • .NET 9+
  • Aspire.Hosting >= 9.5.0
  • Google.Cloud.Spanner.Data >= 5.6.0 (or Google.Cloud.Spanner.V1)

License

Apache-2.0

Product Versions Compatible and additional computed target framework versions.
.NET net9.0 net9.0 is compatible.  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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
9.0.3 109 4/12/2026
9.0.2 96 4/12/2026
9.0.1 105 4/12/2026
9.0.0 114 4/12/2026
8.0.2 108 4/11/2026
8.0.1 119 4/3/2026
8.0.0 101 4/2/2026
7.3.3 104 3/31/2026
7.3.2 102 3/30/2026
7.3.1 101 3/30/2026
7.3.0 111 3/30/2026
7.2.2 108 3/29/2026
7.2.1 104 3/29/2026
7.2.0 110 3/29/2026
7.1.0 105 3/22/2026