Skip to content

Simplify Docker to Azure managed services switch in Aspire AppHost #12366#12368

Merged
yasmoradi merged 5 commits into
bitfoundation:developfrom
yasmoradi:aspire
May 20, 2026
Merged

Simplify Docker to Azure managed services switch in Aspire AppHost #12366#12368
yasmoradi merged 5 commits into
bitfoundation:developfrom
yasmoradi:aspire

Conversation

@yasmoradi
Copy link
Copy Markdown
Member

@yasmoradi yasmoradi commented May 20, 2026

This closes #12366

Summary by CodeRabbit

  • New Features

    • Added simplified infrastructure configuration methods for Redis caching, SQL Server, PostgreSQL, MySQL, SQLite databases, Azure Blob Storage, and MAUI client setup.
  • Chores

    • Updated framework dependencies including Aspire packages to 13.3.4 and Magick.NET to 14.13.1.
    • Removed outdated production migration documentation.
  • Refactor

    • Streamlined application host configuration through higher-level builder APIs.

Review Change Stack

yasmoradi and others added 4 commits May 20, 2026 18:23
…Aspire AppHost bitfoundation#12366

- Add IDistributedApplicationBuilderExtensions with encapsulated resource methods
  (AddRedisCache, AddRedisPersistent, AddSqlServer, AddPostgreSQL, AddMySql,
   AddSqlite, AddAzureStorage, AddMaui) using Azure-native hosting packages
  wrapped with RunAsContainer()/RunAsEmulator() for local dev
- Simplify Program.cs to clean one-liner calls; removing RunAsContainer()
  on any method is now sufficient to switch to the real Azure managed service
- Replace Docker-only NuGet packages with Azure-capable equivalents:
  Aspire.Hosting.SqlServer -> Aspire.Hosting.Azure.Sql
  Aspire.Hosting.PostgreSQL -> Aspire.Hosting.Azure.PostgreSQL
  Aspire.Hosting.Redis + Aspire.Hosting.Azure.Redis (both referenced)
- Bump Aspire package versions to 13.3.4, Magick.NET to 14.13.1
- Update AppHost SDK to 13.3.3
- Remove now-redundant 'Going Production' docs section

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 20, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 199c6d9c-f353-4c43-b127-c7749b0f571f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This PR refactors the Boilerplate template's AppHost infrastructure setup by extracting Docker/Azure provisioning logic into reusable extension methods. Dependencies are upgraded to 13.3.4, Program.cs is simplified from 89 lines of inline container config to clean one-liner calls, and outdated documentation is removed. The abstraction enables developers to switch between local Docker emulators and Azure managed services without rewriting infrastructure code.

Changes

Aspire Infrastructure Abstraction Refactoring

Layer / File(s) Summary
Package version upgrades
src/Directory.Packages.props, src/Server/Boilerplate.Server.AppHost/Boilerplate.Server.AppHost.csproj
Upgraded Aspire hosting/Redis from 13.3.2–13.3.3 to 13.3.4. Replaced conditional package references: Redis switched to Aspire.Hosting.Azure.Redis, SQL Server to Aspire.Hosting.Azure.Sql. Updated AppHost SDK and added Magick.NET 14.13.1.
Infrastructure extension methods
src/Server/Boilerplate.Server.AppHost/Infrastructure/Extensions/IDistributedApplicationBuilderExtensions.cs
New public class with eight extension methods: AddRedisCache() (LRU, no persistence), AddRedisPersistent() (AOF persistence), AddSqlServer(), AddPostgreSQL(), AddMySql(), AddSqlite(), AddAzureStorage() (Azurite emulator), and AddMaui() with multi-platform device target configuration and dev tunnel wiring.
Program.cs infrastructure orchestration
src/Server/Boilerplate.Server.AppHost/Program.cs
Replaced 89 lines of explicit Docker container config (WithDataVolume, WithImage, WithRedisInsight, port bindings) with simplified builder.AddRedisCache(), builder.AddSqlServer(), etc. calls and single-line builder.AddMaui(serverWebProject, tunnel) instead of per-platform device runners.
Documentation cleanup and test markers
.docs/20- .NET Aspire.md, src/Tests/Infrastructure/TestsAssemblyInitializer.cs
Removed outdated "Going Production: Switching to Azure Managed Services" section from Aspire docs (Azure pattern is now encapsulated in extension methods). Added //+:cnd:noEmit marker to test assembly initializer.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Containers once sprawled across the code,
With Docker configs in every mode—
But now extension methods reign supreme,
One line to switch from local dream!
To Azure clouds, no change at all,
Abstraction answers the developer's call. 🚀

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: simplifying the process of switching from Docker-based local services to Azure managed services in the Aspire AppHost.
Linked Issues check ✅ Passed The PR implementation fully addresses issue #12366 by encapsulating resource configuration in extension methods using Azure-native hosting packages and simplifying Program.cs with one-liner calls.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the PR objectives: extension methods for infrastructure, Program.cs simplification, package version updates, and documentation cleanup related to Azure services.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.AppHost/Program.cs`:
- Line 19: The template uses a mismatched database discriminator ("PostgreSql")
so the PostgreSQL setup (builder.AddPostgreSQL()) is skipped; update the
template conditional(s) that check the database discriminator to use the exact
token "PostgreSQL" (capital S and Q) so they align with other files, and verify
any occurrences of the discriminator string in related template conditionals and
resource wiring are normalized to "PostgreSQL" to ensure AddPostgreSQL() is
executed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a523c6d2-fab8-4f3c-8a1f-b59e37726b0a

📥 Commits

Reviewing files that changed from the base of the PR and between c39961b and b35d09b.

📒 Files selected for processing (6)
  • src/Templates/Boilerplate/Bit.Boilerplate/.docs/20- .NET Aspire.md
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Directory.Packages.props
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.AppHost/Boilerplate.Server.AppHost.csproj
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.AppHost/Infrastructure/Extensions/IDistributedApplicationBuilderExtensions.cs
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Server/Boilerplate.Server.AppHost/Program.cs
  • src/Templates/Boilerplate/Bit.Boilerplate/src/Tests/Infrastructure/TestsAssemblyInitializer.cs
💤 Files with no reviewable changes (1)
  • src/Templates/Boilerplate/Bit.Boilerplate/.docs/20- .NET Aspire.md

@yasmoradi yasmoradi merged commit a074040 into bitfoundation:develop May 20, 2026
3 checks passed
@yasmoradi yasmoradi deleted the aspire branch May 20, 2026 17:33
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.

Switching from Docker to Azure managed services in .NET Aspire AppHost requires extensive manual code changes

2 participants