MVFC.Aspire.Helpers.GcpPubSub 9.0.3

dotnet add package MVFC.Aspire.Helpers.GcpPubSub --version 9.0.3
                    
NuGet\Install-Package MVFC.Aspire.Helpers.GcpPubSub -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.GcpPubSub" 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.GcpPubSub" Version="9.0.3" />
                    
Directory.Packages.props
<PackageReference Include="MVFC.Aspire.Helpers.GcpPubSub" />
                    
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.GcpPubSub --version 9.0.3
                    
#r "nuget: MVFC.Aspire.Helpers.GcpPubSub, 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.GcpPubSub@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.GcpPubSub&version=9.0.3
                    
Install as a Cake Addin
#tool nuget:?package=MVFC.Aspire.Helpers.GcpPubSub&version=9.0.3
                    
Install as a Cake Tool

MVFC.Aspire.Helpers.GcpPubSub

πŸ‡§πŸ‡· Leia em PortuguΓͺs

CI codecov License Platform NuGet Version NuGet Downloads

Helpers for integrating with Google Pub/Sub in .NET Aspire projects, including support for the emulator and administration interface (UI).

Motivation

Working with Google Pub/Sub locally usually means:

  • Spinning up an emulator container by hand.
  • Remembering ports, project IDs and environment variables.
  • Manually creating topics/subscriptions and DLQs.

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 topics/subscriptions/DLQs in a consistent way.

MVFC.Aspire.Helpers.GcpPubSub provides:

  • AddGcpPubSub(...) to start the emulator.
  • WithPubSubConfigs(...) to describe topics/subscriptions in code.
  • AddGcpPubSubUI(...) to add a simple web UI.
  • WithReference(...) to wire projects to the emulator and/or UI.

Overview

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

  • Add the Google Pub/Sub emulator.
  • Configure topics and subscriptions automatically.
  • Support push and pull subscriptions.
  • Provide an administration interface (UI) for management.

Pub/Sub emulator advantages

  • Simulates message flow between services locally.
  • Supports testing push and pull subscriptions without depending on Google Cloud infrastructure.
  • Facilitates development and debugging of asynchronous integrations.

Compatible Images

  • Emulator:
    • thekevjames/gcloud-pubsub-emulator
    • messagebird/gcloud-pubsub-emulator
  • UI:
    • echocode/gcp-pubsub-emulator-ui

Project Structure

Features

  • Adds the Google Pub/Sub emulator.
  • Creates topics and subscriptions according to configuration.
  • Supports push and pull subscriptions.
  • Provides a Pub/Sub administration interface (UI).
  • Extension methods to facilitate AppHost configuration.
  • Dead Letter (DLQ) support.

Installation

dotnet add package MVFC.Aspire.Helpers.GcpPubSub

Quick Aspire usage (AppHost)

using Aspire.Hosting;
using MVFC.Aspire.Helpers.GcpPubSub;

var builder = DistributedApplication.CreateBuilder(args);

var messageConfig = new MessageConfig(
    TopicName: "test-topic",
    SubscriptionName: "test-subscription",
    PushEndpoint: "/api/pub-sub-exit")
{
    DeadLetterTopic = "test-dead-letter-topic",
    MaxDeliveryAttempts = 5,
    AckDeadlineSeconds = 300,
};

var pubSubConfig = new PubSubConfig(
    projectId: "test-project",
    messageConfig: messageConfig);

var gcpPubSub = builder.AddGcpPubSub("gcp-pubsub")
    .WithPubSubConfigs([pubSubConfig])
    .WithWaitTimeout(secondsDelay: 5);

var ui = builder.AddGcpPubSubUI("pubsub-ui")
    .WithReference(gcpPubSub)
    .WaitFor(gcpPubSub);

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

await builder.Build().RunAsync();

Topics and subscriptions configuration

PubSubConfig

Parameter Type Default Description
projectId string β€” GCP project ID.
messageConfig MessageConfig β€” Message configuration.
secondsDelay int 5 Startup delay in seconds.

MessageConfig

Parameter Type Default Description
TopicName string β€” Topic name.
SubscriptionName string? null Subscription name.
PushEndpoint string? null HTTP endpoint for push delivery.
DeadLetterTopic string? null Dead letter topic name (DLQ).
MaxDeliveryAttempts int? null Max attempts before sending to DLQ.
AckDeadlineSeconds int? null Ack deadline (seconds).

Note: If DeadLetterTopic is provided, the subscription {DeadLetterTopic}-subscription will be created automatically.

Ports

  • Emulator port: 8681
  • UI port: 8680

Topics and subscriptions diagram

graph TD
A[Pub/Sub Emulator]
B[test-topic]
C[test-subscription push]
D[test-subscription pull]
E[dead-letter-topic]
F[dead-letter-subscription]

A --> B
B --> C
B --> D
C --> E
E --> F

Provisioning diagram

sequenceDiagram
    participant Aspire as .NET Aspire
    participant Container as Pub/Sub Emulator
    participant Configurator as Pub/Sub Processor
    
    Aspire->>Container: Start container (gcloud-pubsub-emulator)
    Container-->>Aspire: Ready (port 8681 available)
    Aspire->>Configurator: Trigger OnResourceReady
    Configurator->>Container: Create Topics
    Configurator->>Container: Create Subscriptions
    Configurator-->>Aspire: Provisioning Completed
    Aspire->>App: Start App with PUBSUB_EMULATOR_HOST

Public methods

  • AddGcpPubSub – adds the emulator.
  • AddGcpPubSubUI – adds the Pub/Sub UI.
  • WithPubSubConfigs – configures projects, topics and subscriptions.
  • WithWaitTimeout – sets startup delay.
  • WithReference – wires projects to emulator/UI and sets env vars.

Requirements

  • .NET 9+
  • Aspire.Hosting >= 9.5.0
  • Google.Cloud.PubSub.V1 >= 3.29.0

License

Apache-2.0

Product 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. 
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 84 4/12/2026
9.0.2 78 4/12/2026
9.0.1 82 4/12/2026
9.0.0 89 4/12/2026
8.0.2 86 4/11/2026
8.0.1 106 4/3/2026
8.0.0 91 4/2/2026
7.3.3 92 3/31/2026
7.3.2 85 3/30/2026
7.3.1 88 3/30/2026
7.3.0 91 3/30/2026
7.2.2 92 3/29/2026
7.2.1 89 3/29/2026
7.2.0 89 3/29/2026
7.1.0 88 3/22/2026
6.4.4 88 3/21/2026
6.4.3 89 3/15/2026
6.4.2 96 3/15/2026
6.4.1 92 3/10/2026
6.4.0 92 3/9/2026
Loading failed