Skip to content

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

@yasmoradi

Description

@yasmoradi

Problem

In the current Boilerplate.Server.AppHost/Program.cs, all infrastructure resources (Redis, SQL Server, PostgreSQL, MySQL, SQLite, Azure Storage, MAUI) are configured inline with Docker-specific container settings (WithDataVolume, WithRedisInsight, WithImage, etc.).

When a developer wants to switch from local Docker containers to real Azure managed services (e.g. for staging or production), they need to:

  • Know which method to replace (e.g. AddRedisAddAzureManagedRedis)
  • Know which Azure-specific packages to add
  • Manually untangle Docker-specific configuration from Azure configuration
  • Make the same change in multiple places

This friction makes the Docker → Azure transition error-prone and undiscoverable.

Expected Behavior

Resource configuration should be encapsulated in extension methods that use Azure-native hosting packages (Aspire.Hosting.Azure.Sql, Aspire.Hosting.Azure.PostgreSQL, Aspire.Hosting.Azure.Redis) wrapped with RunAsContainer() / RunAsEmulator() for local development.

To switch to an actual Azure managed service, the developer simply removes the RunAsContainer() call — no other code changes needed.

Program.cs becomes a clean, readable orchestration file with one-liner calls like:

var redisCache = builder.AddRedisCache();
var sqlDatabase = builder.AddSqlServer();
var postgresDatabase = builder.AddPostgreSQL();

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions