Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couple of problems in the sample #1822

Open
Hypothesys-Smithgor opened this issue Oct 13, 2024 · 0 comments
Open

Couple of problems in the sample #1822

Hypothesys-Smithgor opened this issue Oct 13, 2024 · 0 comments
Assignees
Labels
⌚ Not Triaged Not triaged

Comments

@Hypothesys-Smithgor
Copy link

Hi, I'm running through the sample:

https://learn.microsoft.com/en-us/dotnet/aspire/database/sql-server-integrations

and have found a couple of issues.

Firstly, in the database declaration:

var sql = builder.AddSqlServer("sql", port: 14329)
.AddDatabase("sqldata")
.WithEndpoint(port: 14330);

WithEndpoint shows the following compile error:

The type 'Aspire. Hosting. ApplicationModel. SqlServerDatabaseResource' must be convertible to 'Aspire. Hosting. ApplicationModel. IResourceWithEndpoints' in order to use it as parameter 'T' in the generic method 'IResourceBuilder Aspire. Hosting. ResourceBuilderExtensions. WithEndpoint(this IResourceBuilder, int?, int?, string?, string?, string?, bool, bool?)'

I comment out the WithEndpoint, and run and get an exception:

/aspire-docs-samples/SupportTicketApi/SupportTicketApi.Api/bin/Debug/net8.0/SupportTicketApi.Api
Unhandled exception. Microsoft.Data.SqlClient.SqlException (0x80131904): A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - Undefined error: 0)

It appears to be a timing issue (presumably because the container is not fully up and running). If I run in debug and put a breakpoint on:

    var context = scope.ServiceProvider.GetRequiredService<TicketContext>();

in Api.Program.cs, then continue, all works as intented.

Is there a way to delay until the container is fully provisioned?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⌚ Not Triaged Not triaged
Projects
None yet
Development

No branches or pull requests

2 participants