dotnet / aspire-samples

MIT License
560 stars 153 forks source link

Guard against billing surprises - DatabaseMigrations sample #300

Open collinbarrett opened 1 month ago

collinbarrett commented 1 month ago

The DatabaseMigrations sample is working great for me in local development. However, by default, it's included when I azd up. The MigrationService seems to get deployed as an Azure Container App 'App' type rather than 'Job' type (docs), so Container Apps continually reboots it even if the migration completes successfully.

I discovered this when I looked at my Azure SQL Database free offer quota. Stopping the MigrationService container in Azure Portal caused the inflection in this chart of a db for an app still under development (no usage expected other than when I'm working on it).

image

Does Aspire have tooling to provision a 'Job' type yet?

If not, maybe we update this sample to prevent surprises? Something like the below here?

if (builder.ExecutionContext.IsRunMode) {
    builder.AddProject<Projects.DatabaseMigrations_MigrationService>("migration")
           .WithReference(db1);
}