diff --git a/playground/DatabaseMigration/DatabaseMigration.AppHost/aspire-manifest.json b/playground/DatabaseMigration/DatabaseMigration.AppHost/aspire-manifest.json index 4e97414be1..4e772b7d4d 100644 --- a/playground/DatabaseMigration/DatabaseMigration.AppHost/aspire-manifest.json +++ b/playground/DatabaseMigration/DatabaseMigration.AppHost/aspire-manifest.json @@ -3,7 +3,7 @@ "resources": { "sql1": { "type": "container.v0", - "connectionString": "Server={sql1.bindings.tcp.host},{sql1.bindings.tcp.port};User ID=sa;Password={sql1-password.value};TrustServerCertificate=true", + "connectionString": "Server={sql1.bindings.tcp.host},{sql1.bindings.tcp.port};User ID=sa;Password={sql1-password.value};TrustServerCertificate=true;Integrated Security=false", "image": "mcr.microsoft.com/mssql/server:2022-latest", "env": { "ACCEPT_EULA": "Y", @@ -77,4 +77,4 @@ } } } -} \ No newline at end of file +} diff --git a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/aspire-manifest.json b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/aspire-manifest.json index 5f611ac2d5..1e81e1cdf2 100644 --- a/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/aspire-manifest.json +++ b/playground/SqlServerEndToEnd/SqlServerEndToEnd.AppHost/aspire-manifest.json @@ -16,7 +16,7 @@ }, "sql2": { "type": "container.v0", - "connectionString": "Server={sql2.bindings.tcp.host},{sql2.bindings.tcp.port};User ID=sa;Password={sql2-password.value};TrustServerCertificate=true", + "connectionString": "Server={sql2.bindings.tcp.host},{sql2.bindings.tcp.port};User ID=sa;Password={sql2-password.value};TrustServerCertificate=true;Integrated Security=false", "image": "mcr.microsoft.com/mssql/server:2022-latest", "env": { "ACCEPT_EULA": "Y", @@ -106,4 +106,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/Aspire.Hosting.SqlServer/SqlServerServerResource.cs b/src/Aspire.Hosting.SqlServer/SqlServerServerResource.cs index ab114a9cc0..31b525d755 100644 --- a/src/Aspire.Hosting.SqlServer/SqlServerServerResource.cs +++ b/src/Aspire.Hosting.SqlServer/SqlServerServerResource.cs @@ -35,7 +35,7 @@ public SqlServerServerResource(string name, ParameterResource password) : base(n private ReferenceExpression ConnectionString => ReferenceExpression.Create( - $"Server={PrimaryEndpoint.Property(EndpointProperty.IPV4Host)},{PrimaryEndpoint.Property(EndpointProperty.Port)};User ID=sa;Password={PasswordParameter};TrustServerCertificate=true"); + $"Server={PrimaryEndpoint.Property(EndpointProperty.IPV4Host)},{PrimaryEndpoint.Property(EndpointProperty.Port)};User ID=sa;Password={PasswordParameter};TrustServerCertificate=true;Integrated Security=false"); /// /// Gets the connection string expression for the SQL Server. @@ -57,7 +57,7 @@ public ReferenceExpression ConnectionStringExpression /// Gets the connection string for the SQL Server. /// /// A to observe while waiting for the task to complete. - /// A connection string for the SQL Server in the form "Server=host,port;User ID=sa;Password=password;TrustServerCertificate=true". + /// A connection string for the SQL Server in the form "Server=host,port;User ID=sa;Password=password;TrustServerCertificate=true;Integrated Security=false". public ValueTask GetConnectionStringAsync(CancellationToken cancellationToken = default) { if (this.TryGetLastAnnotation(out var connectionStringAnnotation)) diff --git a/tests/Aspire.Hosting.Azure.Tests/AzureSqlExtensionsTests.cs b/tests/Aspire.Hosting.Azure.Tests/AzureSqlExtensionsTests.cs index 29d0ae5d09..603dfcb752 100644 --- a/tests/Aspire.Hosting.Azure.Tests/AzureSqlExtensionsTests.cs +++ b/tests/Aspire.Hosting.Azure.Tests/AzureSqlExtensionsTests.cs @@ -161,15 +161,15 @@ public async Task AddAzureSqlServerRunAsContainerProducesCorrectConnectionString Assert.True(sql.Resource.IsContainer(), "The resource should now be a container resource."); var serverConnectionString = await sql.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); Assert.StartsWith("Server=127.0.0.1,12455;User ID=sa;Password=", serverConnectionString); - Assert.EndsWith(";TrustServerCertificate=true", serverConnectionString); + Assert.EndsWith(";TrustServerCertificate=true;Integrated Security=false", serverConnectionString); var db1ConnectionString = await db1.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); Assert.StartsWith("Server=127.0.0.1,12455;User ID=sa;Password=", db1ConnectionString); - Assert.EndsWith(";TrustServerCertificate=true;Database=db1", db1ConnectionString); + Assert.EndsWith(";TrustServerCertificate=true;Integrated Security=false;Database=db1", db1ConnectionString); var db2ConnectionString = await db2.Resource.ConnectionStringExpression.GetValueAsync(CancellationToken.None); Assert.StartsWith("Server=127.0.0.1,12455;User ID=sa;Password=", db2ConnectionString); - Assert.EndsWith(";TrustServerCertificate=true;Database=db2Name", db2ConnectionString); + Assert.EndsWith(";TrustServerCertificate=true;Integrated Security=false;Database=db2Name", db2ConnectionString); } [Theory] diff --git a/tests/Aspire.Hosting.SqlServer.Tests/AddSqlServerTests.cs b/tests/Aspire.Hosting.SqlServer.Tests/AddSqlServerTests.cs index 1e0162fbdd..eb0be7fc6f 100644 --- a/tests/Aspire.Hosting.SqlServer.Tests/AddSqlServerTests.cs +++ b/tests/Aspire.Hosting.SqlServer.Tests/AddSqlServerTests.cs @@ -94,8 +94,8 @@ public async Task SqlServerCreatesConnectionString() var connectionStringResource = Assert.Single(appModel.Resources.OfType()); var connectionString = await connectionStringResource.GetConnectionStringAsync(default); - Assert.Equal("Server=127.0.0.1,1433;User ID=sa;Password=p@ssw0rd1;TrustServerCertificate=true", connectionString); - Assert.Equal("Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={pass.value};TrustServerCertificate=true", connectionStringResource.ConnectionStringExpression.ValueExpression); + Assert.Equal("Server=127.0.0.1,1433;User ID=sa;Password=p@ssw0rd1;TrustServerCertificate=true;Integrated Security=false", connectionString); + Assert.Equal("Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={pass.value};TrustServerCertificate=true;Integrated Security=false", connectionStringResource.ConnectionStringExpression.ValueExpression); } [Fact] @@ -118,7 +118,7 @@ public async Task SqlServerDatabaseCreatesConnectionString() var connectionStringResource = (IResourceWithConnectionString)sqlResource; var connectionString = await connectionStringResource.GetConnectionStringAsync(); - Assert.Equal("Server=127.0.0.1,1433;User ID=sa;Password=p@ssw0rd1;TrustServerCertificate=true;Database=mydb", connectionString); + Assert.Equal("Server=127.0.0.1,1433;User ID=sa;Password=p@ssw0rd1;TrustServerCertificate=true;Integrated Security=false;Database=mydb", connectionString); Assert.Equal("{sqlserver.connectionString};Database=mydb", connectionStringResource.ConnectionStringExpression.ValueExpression); } @@ -135,7 +135,7 @@ public async Task VerifyManifest() var expectedManifest = $$""" { "type": "container.v0", - "connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={sqlserver-password.value};TrustServerCertificate=true", + "connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={sqlserver-password.value};TrustServerCertificate=true;Integrated Security=false", "image": "{{SqlServerContainerImageTags.Registry}}/{{SqlServerContainerImageTags.Image}}:{{SqlServerContainerImageTags.Tag}}", "env": { "ACCEPT_EULA": "Y", @@ -175,7 +175,7 @@ public async Task VerifyManifestWithPasswordParameter() var expectedManifest = $$""" { "type": "container.v0", - "connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={pass.value};TrustServerCertificate=true", + "connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={pass.value};TrustServerCertificate=true;Integrated Security=false", "image": "{{SqlServerContainerImageTags.Registry}}/{{SqlServerContainerImageTags.Image}}:{{SqlServerContainerImageTags.Tag}}", "env": { "ACCEPT_EULA": "Y", diff --git a/tests/testproject/TestProject.AppHost/aspire-manifest.json b/tests/testproject/TestProject.AppHost/aspire-manifest.json index 786f8de338..465cc7ce56 100644 --- a/tests/testproject/TestProject.AppHost/aspire-manifest.json +++ b/tests/testproject/TestProject.AppHost/aspire-manifest.json @@ -152,7 +152,7 @@ }, "sqlserver": { "type": "container.v0", - "connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={sqlserver-password.value};TrustServerCertificate=true", + "connectionString": "Server={sqlserver.bindings.tcp.host},{sqlserver.bindings.tcp.port};User ID=sa;Password={sqlserver-password.value};TrustServerCertificate=true;Integrated Security=false", "image": "mcr.microsoft.com/mssql/server:2022-latest", "env": { "ACCEPT_EULA": "Y",