Skip to content

Sql Server container port is not accessible after Aspire is shutdown #7046

@christophe-mommer

Description

@christophe-mommer

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I'm using Aspire to orchestrate my webapp and my database. I'm also using this database as part of several other projects, like test project.
Here's my setup:

var password = builder.AddParameter("sqlpassword", secret: true);
var sqlServer = builder
    .AddSqlServer(ConfigurationConstants.SqlServerConnectionName, password, 1433)
    .WithLifetime(ContainerLifetime.Persistent)
    .WithDataVolume(name: ConfigurationConstants.SqlServerDataVolumeName, isReadOnly: false)
    .WithContainerName("sql-server");

var sqlDatabase = sqlServer.AddDatabase(ConfigurationConstants.SqlDatabaseConnectionName);

webFrontEnd
    .WithReference(sqlDatabase)
    .WaitFor(sqlDatabase);

The thing is: when my Aspire app si running, I can access the database on port 1433 from other applications, even SSMS. However, when I shutdown my Aspire project, this database is no more accessible, even though it's marked as persistent. The container is still there, but the random port is the only one that allows me to acces the database, not the 1433 that I've specified.

Have I missed something in my configuration?

Expected Behavior

No response

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version info

.NET 9, Aspire 9

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area-app-modelIssues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplicationarea-orchestrator

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions