Skip to content

feat(floci): model Service Bus as a child resource of AddFlociAzure - #1555

Open
thomhurst wants to merge 6 commits into
CommunityToolkit:mainfrom
thomhurst:floci-servicebus-reference
Open

feat(floci): model Service Bus as a child resource of AddFlociAzure#1555
thomhurst wants to merge 6 commits into
CommunityToolkit:mainfrom
thomhurst:floci-servicebus-reference

Conversation

@thomhurst

@thomhurst thomhurst commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Fixes #1552.

Adds WithServiceBus() to model the Floci Azure Service Bus AMQP data plane as a child resource. The emulator starts its Artemis sidecar at boot, and Aspire allocates proxyless AMQP/AMQPS endpoints. Referencing the child injects the connection string used by AddAzureServiceBusClient("servicebus").

var azure = builder.AddFlociAzure("floci-az").WithDockerSocket();
var serviceBus = azure.WithServiceBus();

builder.AddProject<MyApi>("api")
    .WithReference(serviceBus)
    .WaitFor(azure);

Requires floci-az 0.12.0, already pinned on this branch. That release includes namespace startup, batched sends, and .NET administration-client routing. The management plane remains on the parent emulator endpoint. Multiple emulator instances on one Docker host need distinct FLOCI_AZ_DOCKER_RESOURCE_NAMESPACE values; the README documents this requirement.

Validation includes eight unit tests and two Docker integration cases. The integration cases start the real emulator, verify both listeners before queue creation, resolve the consumer's WithReference environment, create a queue with ServiceBusAdministrationClient, and send, receive, and complete single messages and a three-message batch with ServiceBusClient. Each case uses an isolated Docker namespace and a bounded timeout.

Also fixes the TypeScript sample's bind mount to create a portable local directory instead of assuming /tmp/floci-data exists. The branch includes current main, which removes the obsolete Source Link dependency that blocked restore.

Local validation: dotnet test --project tests/CommunityToolkit.Aspire.Hosting.Floci.Tests -c Release --no-progress --output Normal passed all 75 tests, with no skips, including TypeScript AppHost compilation/startup and the Docker integration cases. NuGet audit remained enabled.

WithServiceBus() adds a FlociAzureServiceBusResource child that enables the
floci-az Service Bus data plane (MOCKED=false, START_ON_BOOT=true) and pins
the host ports its Artemis sidecar publishes — free ports by default so
concurrent AppHosts don't collide. Referencing the child with Aspire's
standard WithReference injects the official emulator's connection-string
shape (Endpoint=sb://localhost:{port};...;UseDevelopmentEmulator=true;) so
AddAzureServiceBusClient works unchanged.

The sidecar publishes directly on the Docker host, outside Aspire's endpoint
model, so the endpoint is host-relative; the management plane stays on the
base endpoint from WithReference(azure).

Blocked on a floci-az release with start-on-boot support
(floci-io/floci-az#249, PR floci-io/floci-az#250).

Fixes CommunityToolkit#1552

Claude-Session: https://claude.ai/code/session_01K8waTF6dPtQNUmXz3i8xnG
Comment thread src/CommunityToolkit.Aspire.Hosting.Floci/FlociHostingExtension.Azure.cs Outdated
@aaronpowell

Copy link
Copy Markdown
Member

@thomhurst - are you interested in being added as a contributor and being given the CODEOWNER for the floci integration?

Model sidecar ports as proxyless endpoints so DCP allocates them before the Floci container environment resolves.
@thomhurst

Copy link
Copy Markdown
Contributor Author

Happy to be added as a contributor but not sure I'll have time to be a code owner and review all the changes if it gets busy

@aaronpowell

Copy link
Copy Markdown
Member

Well, the floci changes seem to mostly come from you 😅

@aaronpowell aaronpowell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to merge when the external blocker is resolved.

@afscrome

Copy link
Copy Markdown
Contributor

Looks like this got released in https://github.com/floci-io/floci-az/releases/tag/0.12.0 . Is this Pr ready for review?

@thomhurst
thomhurst marked this pull request as ready for review September 12, 2026 11:35
Copilot AI lite review requested due to automatic review settings September 12, 2026 11:35

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

Unresolved critical issues affect container connectivity, child-name uniqueness, and endpoint validation.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds Floci Azure Service Bus child-resource support with AMQP/AMQPS endpoints, connection-string injection, documentation, and integration coverage.

Changes:

  • Adds WithServiceBus() and Service Bus resource modeling.
  • Configures emulator startup and endpoint allocation.
  • Adds unit and Docker functional tests.
  • Updates documentation and package dependencies.
File summaries
File Summary
tests/CommunityToolkit.Aspire.Hosting.Floci.Tests/CommunityToolkit.Aspire.Hosting.Floci.Tests.csproj Adds the Service Bus SDK test dependency.
tests/CommunityToolkit.Aspire.Hosting.Floci.Tests/AzureServiceBusResourceTests.cs Tests Service Bus resource behavior.
tests/CommunityToolkit.Aspire.Hosting.Floci.Tests/AzureServiceBusFunctionalTests.cs Verifies real emulator messaging operations.
src/CommunityToolkit.Aspire.Hosting.Floci/README.md Documents Service Bus usage and runtime requirements.
src/CommunityToolkit.Aspire.Hosting.Floci/FlociHostingExtension.Azure.cs Adds Service Bus configuration and export support.
src/CommunityToolkit.Aspire.Hosting.Floci/FlociAzureServiceBusResource.cs Defines the Service Bus child resource and connection properties.
Directory.Packages.props Pins the Service Bus SDK version.
Review details

Suppressed comments (1)

src/CommunityToolkit.Aspire.Hosting.Floci/FlociHostingExtension.Azure.cs:113

  • When a parent already has a child, this branch ignores name and returns the existing resource after checking only ports. Thus azure.WithServiceBus("first"); azure.WithServiceBus("second") returns a builder whose resource is still first, so a later WithReference injects the wrong connection-string key. Reject a different name (or otherwise honor it) before returning.
        if (existing is not null)
        {
            int? existingAmqpPort = existing.AmqpEndpoint.EndpointAnnotation.Port;
            int? existingAmqpTlsPort = existing.AmqpTlsEndpoint.EndpointAnnotation.Port;
            if ((amqpPort is not null && amqpPort != existingAmqpPort)
  • Files reviewed: 8/8 changed files
  • Comments generated: 5
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +55 to +57
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create(
$"Endpoint={AmqpEndpoint};SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey={DefaultSasKey};UseDevelopmentEmulator=true;");
Comment on lines +103 to +104
ArgumentNullException.ThrowIfNull(builder);
ArgumentException.ThrowIfNullOrWhiteSpace(name);
Comment on lines +123 to +125
var serviceBus = new FlociAzureServiceBusResource(name, builder.Resource);
var serviceBusBuilder = builder.ApplicationBuilder
.AddResource(serviceBus)
Comment on lines +140 to +143
if (context.ExecutionContext.IsPublishMode)
{
return;
}
Comment on lines +96 to +97
[AspireExport]
public static IResourceBuilder<FlociAzureServiceBusResource> WithServiceBus(
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.

[Feature]: CommunityToolkit.Aspire.Hosting.Floci — Service Bus connection string helper for AddFlociAzure

4 participants