Aspire: Deployment stuck in "Pending" state when using Aspire.Hosting.Azure.Sql locally

Describe the bug

When using AddAzureSqlServer("").RunAscontainer() using the Aspire.Hosting.Azure.Sql package, the deployment just hangs. No error, no logs…just hanging, and deployment reports “Pending” as a status.

Regression

No response

Steps to reproduce

var sqlSrv = builder.AddAzureSqlServer("sql")
    .RunAsContainer();    

var sqlDb = sqlSrv.AddDatabase("aspiretodo");

var dbPrj = builder.AddSqlProject<Projects.TodoDB>("tododb")    
    .WithReference(sqlDb)    
    .WaitFor(sqlDb);

Expected behavior

Deploy the database project

Screenshots

No response

IDE and version

Other

IDE version

VS Code

Nuget packages

<PackageReference Include="Aspire.Hosting.AppHost" Version="9.1.0" />
<PackageReference Include="Aspire.Hosting.Azure.Sql" Version="9.1.0" />
<PackageReference Include="Aspire.Hosting.NodeJs" Version="9.1.0" />
<PackageReference Include="Aspire.Hosting.SqlServer" Version="9.1.0" />
<PackageReference Include="CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder" Version="9.2.0" />
<PackageReference Include="CommunityToolkit.Aspire.Hosting.NodeJS.Extensions" Version="9.2.0" />
<PackageReference Include="CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects" Version="9.2.1" />

Additional context

No response

Help us help you

Yes, I’d like to be assigned to work on this item

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 28 (21 by maintainers)

Most upvoted comments

builder.ApplicationBuilder.Eventing.Subscribe<AfterResourcesCreatedEvent>(async (@event, ct) => {
    await RunPublish(builder, target, targetDatabaseName, @event.Services, ct);
});

If the RunAsContainer method was updated for eventing, I think this would work out of the box with the current implementation

@yorek Thanks, I think you will agree that it takes more than this little NuGet package to accomplish this!

@ErikEJ I would definitely want to support the ability to deploy a .dacpac to an Azure SQL-like container during local development. One might argue that at least for local-dev there really isn’t a distinction between Azure SQL and SQL Server.

Not sure why it gets stuck into a pending state though. If the target resource is not a SqlServerDatabaseResource, which I’m assuming is the case here, we start deploying as soon as all resources have been created (AfterResourcesCreatedEvent).

@yorek We seem to be discussing at least two topics here

  • local deployment support
  • general production deployment support for SQL Projects

Maybe you should open a new issue for the second topic?

Did you try what @aaronpowell suggested above?

@jmezach Any thoughts on this issue - it would be a great scenario to support.