Skip to content

feat: add RavenDB Cloud hosting integration - #2413

Merged
aaronpowell merged 1 commit into
CommunityToolkit:mainfrom
poissoncorp:feat/ravendb-cloud
Dec 2, 2026
Merged

aaronpowell merged 1 commit into
CommunityToolkit:mainfrom
poissoncorp:feat/ravendb-cloud

Conversation

@poissoncorp

@poissoncorp poissoncorp commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2412

Adds CommunityToolkit.Aspire.Hosting.RavenDB.Cloud (preview): aspire deploy creates or finds a RavenDB Cloud product and hands every application that references the RavenDB server the product's node URLs and a client certificate of its own. aspire run keeps the local container.

builder.AddRavenDB("ravendb")
    .PublishAsRavenDBCloud(apiKey, "shop-production",
        RavenDBCloudSpec.Production(
            RavenDBCloudProvider.Azure,
            region: "westeurope",
            instanceType: "P20",
            diskSizeInGb: 128,
            RavenDBCloudStorageType.SsdStandard,
            RavenDBCloudDiskLayout.SingleDataDisk,
            releaseChannel: "Stable72"),
        cloud => cloud.WithAllowedIps("203.0.113.0/24"))
    .AddDatabase("orders", ensureCreated: true);

What changes where

  • Hosting.RavenDB (base): a small API for deployment packages, marked [Experimental("CTASPIRERAVENDB001")] and documented in docs/diagnostics.md: WithPublishStrategy publishes the server with a deployment package's URL instead of its container, and RavenDBServerResource.PublishStrategy and DatabasesToCreate expose what a deployment needs. AppHosts never call it, and the base package uses no experimental Aspire API.
  • src/Shared/RavenDB: finding the applications that reference a server, and writing their client settings, compiled into the deployment packages that need it.
  • RavenDB.Client: CertificateBase64, so a certificate can arrive as a value (an environment variable) instead of a file; CreateDatabase checks that the database exists by listing the databases the certificate may access, so an application whose certificate only reaches its own database still starts; the connection string's URL may list a cluster's nodes separated by commas.
  • Hosting.RavenDB.Cloud (new):
    • managed (PublishAsRavenDBCloud, the AppHost owns the product and its spec) and attached (PublishAsExistingRavenDBCloud) modes;
    • the spec has no defaults: tier, provider, region, instance type, disk size, storage type, disk layout and release channel are all explicit;
    • a plan step that runs before anything is built and shows what the deployment will do; changes need explicit approval from the environment of the process that deploys, never from a committed file, and changes RavenDB Cloud cannot make stop the deployment;
    • the plan checks the spec against what RavenDB Cloud offers the account and lists the valid regions, instance types and release channels when a value is not offered;
    • per-application certificates, admin on the application's own databases only, issued on every deployment; the previous ones are revoked once the applications run, and only certificates the AppHost issued are ever revoked;
    • the applications get every node of the product, so they reach the cluster while one node is down;
    • the URL and certificates are deploy-time values that the compute environment delivers; v1 supports Docker Compose, where they land in the .env file;
    • aspire destroy terminates the product only with TerminateOnDestroy, and refuses a product that does not match the AppHost.
  • C# and TypeScript examples, README for each package, a row in the root README.

Testing

  • Unit tests against an in-memory Cloud API and RavenDB server: 95 in the Cloud test project, including full Aspire pipeline runs and the TypeScript example through the Aspire CLI; 29 in the hosting package; 24 in the client package, against an embedded RavenDB server.
  • PlanAgainstTheCloudApi plans the TypeScript example against the real Cloud API. Like the other tests that need an authenticated external service, it is marked RequiresAuthenticatedTool and skipped on CI; locally it runs when RAVENDB_CLOUD_API_KEY is set.
  • End-to-end runs against RavenDB Cloud: product creation, application traffic through Docker Compose, certificate rotation, a change stopped and then approved, attached mode, and destroy with termination.

PR Checklist

  • Created a feature/dev branch in your fork (vs. submitting directly from a commit on main)
  • Based off latest main branch of toolkit
  • PR doesn't include merge commits (always rebase on top of our main, if needed)
  • New integration
    • Docs are written
    • Added description of major feature to project description for NuGet package
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Contains NO breaking changes
  • Every new API (including internal ones) has full XML docs
  • Code follows all style conventions

Other information

  • The Cloud package is separate from the base package, so applications that do not deploy to RavenDB Cloud do not take it on. It ships as a preview, so that its API can still change without waiting for a major version.
  • Azure Container Apps would carry the certificate as a plain template parameter, so the plan stops for applications outside Docker Compose. Support through Azure Key Vault and a Kubernetes package built on the RavenDB operator are planned as follow-ups.
  • The public API grows by RavenDBClientSettings.CertificateBase64 in the client and by the experimental deployment API in the hosting package; the api/*.cs baselines are left to the repository's tooling.
  • The RavenDB team owns the Cloud package in CODEOWNERS, like the other RavenDB packages, which are now owned by @ppekrol, @poissoncorp and @karmeli87.
  • The Cloud package relies on Aspire's pipeline step names and on Docker Compose resolving deploy-time values; the tests cover both.

@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.sh | bash -s -- 2413

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/CommunityToolkit/Aspire/main/eng/scripts/dogfood-pr.ps1) } 2413"

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Database-existence checks can wrongly trigger creation and block startup, while certificate aliasing and identifier collisions can cause HTTPS validation failures or deliver another product’s credentials.

5 open issues
1 file not reviewed
  • examples/ravendb/CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/package-lock.json: Generated file
What changed in this PR

Adds a preview RavenDB Cloud deployment integration alongside the existing local-container integration, addressing #2412. Docker Compose applications receive cluster URLs and individual client certificates while local development remains container-based.

Changes:

  • Adds managed and attached Cloud deployments, planning, approval checks, certificate rotation, and guarded teardown.
  • Extends RavenDB hosting and client support for deployment strategies, certificate configuration, and multiple node URLs.
  • Adds tests, C# and TypeScript examples, documentation, and package ownership.
File Description
tests/​CommunityToolkit.Aspire.RavenDB.Client.Tests/​RavenDBClientConnectionStringTests.cs Tests multi-node connection strings.
tests/​CommunityToolkit.Aspire.RavenDB.Client.Tests/​RavenDBClientCertificateTests.cs Tests certificate configuration and errors.
tests/​CommunityToolkit.Aspire.RavenDB.Client.Tests/​AspireRavenDBExtensionsTests.cs Tests reuse of existing databases.
tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Tests/​RavenDBPublishStrategyTests.cs Tests alternate publishing behavior.
tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/​TypeScriptAppHostTests.cs Exercises TypeScript publishing and planning.
tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/​RavenDBConsumersTests.cs Tests consumer discovery and certificate settings.
tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/​RavenDBCloudPublishTests.cs Tests deployment pipeline behavior and safeguards.
tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/​RavenDBCloudProductsTests.cs Tests product lifecycle and certificate rotation.
tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/​RavenDBCloudPlanTests.cs Tests planning and configuration validation.
tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/​Fakes.cs Provides in-memory deployment test dependencies.
tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.Tests.csproj Defines the Cloud test project.
src/​Shared/​RavenDB/​RavenDBConsumers.cs Discovers referencing applications and databases.
src/​Shared/​RavenDB/​RavenDBClientConfiguration.cs Delivers certificate configuration to consumers.
src/​CommunityToolkit.Aspire.RavenDB.Client/​README.md Documents certificates and cluster URLs.
src/​CommunityToolkit.Aspire.RavenDB.Client/​RavenDBClientSettings.cs Adds base64 certificate configuration.
src/​CommunityToolkit.Aspire.RavenDB.Client/​RavenDBClientExtension.cs Updates URL parsing and database existence checks.
src/​CommunityToolkit.Aspire.Hosting.RavenDB/​README.md Introduces the Cloud deployment option.
src/​CommunityToolkit.Aspire.Hosting.RavenDB/​RavenDBServerResource.cs Exposes deployment strategy and database metadata.
src/​CommunityToolkit.Aspire.Hosting.RavenDB/​RavenDBPublishStrategy.cs Adds alternate publishing and wait removal.
src/​CommunityToolkit.Aspire.Hosting.RavenDB/​RavenDBBuilderExtensions.cs Records databases requiring creation.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​README.md Documents deployment, security, and limitations.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBServerAdministration.cs Implements server administration operations.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudValues.cs Models deploy-time URLs and certificates.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudSpec.cs Defines explicit product specifications.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudProducts.cs Implements provisioning and guarded termination.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudPlan.cs Validates specifications and plans changes.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudPipelineSteps.cs Coordinates deployment and destroy steps.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudOptions.cs Defines Cloud options and enums.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudEnvironment.cs Reads deployment process environment settings.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudDeployment.cs Holds deployment configuration and state.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudCertificates.cs Issues and revokes application certificates.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudBuilderExtensions.cs Adds managed and attached publishing APIs.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​RavenDBCloudApiClient.cs Implements Cloud API requests and retries.
src/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.csproj Defines the preview hosting package.
README.md Adds the Cloud integration to the catalog.
examples/​ravendb/​RavenDB.Cloud.AppHost/​Properties/​launchSettings.json Configures local example launch settings.
examples/​ravendb/​RavenDB.Cloud.AppHost/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.csproj Defines the C# example project.
examples/​ravendb/​RavenDB.Cloud.AppHost/​AppHost.cs Demonstrates Cloud publishing in C#.
examples/​ravendb/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/​tsconfig.json Configures TypeScript compilation.
examples/​ravendb/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/​package.json Defines example dependencies and scripts.
examples/​ravendb/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/​eslint.config.mjs Checks asynchronous AppHost calls.
examples/​ravendb/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/​aspire.config.json Configures Aspire and integration references.
examples/​ravendb/​CommunityToolkit.Aspire.Hosting.RavenDB.Cloud.AppHost.TypeScript/​apphost.mts Demonstrates Cloud publishing in TypeScript.
docs/​diagnostics.md Documents the experimental hosting API diagnostic.
CommunityToolkit.Aspire.slnx Registers the package, tests, and C# example.
CODEOWNERS Updates RavenDB ownership and covers Cloud files.

Review effort: Balanced


/// <summary>An application's client certificate, as base64-encoded .pfx content.</summary>
internal sealed class RavenDBCloudCertificate(RavenDBServerResource server, IResource consumer)
: RavenDBCloudDeployTimeValue($"{{{server.Name}-{consumer.Name}.certificate}}")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the AppHost now stops before anything runs when two deploy-time values would share a Docker Compose variable, and the error names both resources. Covered by ValuesThatWouldShareAComposeVariableAreAnError.

{
var names = documentStore.Maintenance.Server.Send(new GetDatabaseNamesOperation(start, pageSize));

if (names.Any(name => string.Equals(name, databaseName, StringComparison.OrdinalIgnoreCase)))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the client now asks the server about that one database (GET /databases?name=...), which finds a sharded database by its own name and needs no permission beyond access to that database. AddRavenDbClient_CreateDatabaseUsesAnExistingShardedDatabase reproduces the failure with the previous check and passes now.

Comment on lines +242 to +244
if (names.Length < pageSize)
{
return false;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed by the same change: looking up one database involves no paging, so permission filtering cannot hide it. The client tests run against an unsecured embedded server, so a restricted certificate cannot be reproduced there; a deployment to RavenDB Cloud in which the application starts with CreateDatabase = true and a certificate limited to its own database passes with the new check.

Comment thread src/Shared/RavenDB/RavenDBConsumers.cs Outdated
continue;
}

connectionNames.Add(referenced.Name);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the certificate now goes under the names the application gets the server's connection strings by, read from the environment WithReference writes, so a connection renamed with connectionName gets it too. Covered by WithSeveralServersTheCertificateGoesUnderTheConnectionNamesOnly.


var sizes = type.Parameters?.AvailableDiskSizes?.Where(s => s > 0).ToList() ?? [];

if (sizes.Count > 0 && !sizes.Contains(spec.DiskSizeInGb))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed: the instance type's offered sizes are checked only when creating a product. An existing disk keeps its size, including one RavenDB Cloud grew past that list, never shrinks, and grows only to the sizes RavenDB Cloud lists for that disk (availableDiskSizes in the product details). Covered by DiskRavenDBCloudGrewIsNoChange and DiskGrowsOnlyToTheSizesRavenDBCloudListsForIt.

Adds CommunityToolkit.Aspire.Hosting.RavenDB.Cloud (preview): aspire deploy
creates or finds a RavenDB Cloud product and gives every application that
references the RavenDB server the product's node URLs and a client certificate
of its own; aspire run keeps the local container.

- Hosting.RavenDB: an experimental publish strategy API (CTASPIRERAVENDB001)
  the Cloud package plugs into.
- RavenDB.Client: a certificate as a value (CertificateBase64), several node
  URLs in the connection string, and CreateDatabase that works with a
  certificate scoped to its own database.
- CODEOWNERS: the RavenDB owners are ppekrol, poissoncorp and karmeli87.
@poissoncorp

Copy link
Copy Markdown
Contributor Author

@aaronpowell this is ready for review: the RavenDB code owners approved, and CI is green apart from two runner failures outside RavenDB (Dapr container networking on Ubuntu, the Kind tests on Windows).

@aaronpowell
aaronpowell merged commit 0aaf980 into CommunityToolkit:main Dec 2, 2026
178 of 180 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RavenDB Cloud hosting integration for aspire deploy

4 participants